Exemplo n.º 1
0
        protected override void populateDestructibleElements()
        {
            base.populateDestructibleElements();

            AudioManager.Instance.startSound(musicToPlay);
            if (this.secondToPlay == 0)
            {
                this.secondToPlay = AudioManager.Instance.getLength(musicToPlay);
            }

            #region Start animation
            if (instrumentHash == InstrumentHash.Guitar)
            {
                Ped player = Game.Player.Character;

                while (instrumentProp == null)
                {
                    instrumentProp = World.CreateProp("prop_acc_guitar_01", player.Position + player.ForwardVector * 4.0f, true, true);
                }

                instrumentProp.HasCollision = true;
                instrumentProp.HasGravity   = true;
                instrumentProp.AttachTo(player, player.GetBoneIndex(Bone.SKEL_Pelvis), new Vector3(-0.18f, 0.28f, -0.1f), new Vector3(195f, -24f, 0f));
                player.Task.ClearAllImmediately();
                player.Task.PlayAnimation("amb@world_human_musician@guitar@male@base", "base", 8f, -1, true, -1f);
            }
            #endregion
        }
Exemplo n.º 2
0
        /// <summary>
        /// 車両を掴む
        /// </summary>
        private void GripVehicle(Ped ped, Vehicle vehicle, Vector3 ofsetPosition)
        {
            ped.SetToRagdoll(0, 1);
            SetPedProof(ped, true);
            var forceToBreak = 10000.0f;
            var rotation     = new Vector3(0.0f, 0.0f, 0.0f);
            var isCollision  = true;

            Function.Call(Hash.ATTACH_ENTITY_TO_ENTITY_PHYSICALLY,
                          ped,
                          vehicle,
                          ped.GetBoneIndex(Bone.SKEL_R_Hand),
                          vehicle.GetBoneIndex("SKEL_ROOT"),
                          ofsetPosition.X,
                          ofsetPosition.Y,
                          ofsetPosition.Z,
                          0.0f,
                          0.0f,
                          0.0f,
                          rotation.X,
                          rotation.Y,
                          rotation.Z,
                          forceToBreak,
                          false, //?
                          false, //?
                          isCollision,
                          false, //?
                          2);    //?
        }
Exemplo n.º 3
0
        public static int GetNearestBoneIndex(Ped ped, Vector3 hitPosition)
        {
            if (ped == null)
            {
                return(0);
            }

            float shortestBoneDistance = float.MaxValue;
            int   nearestBoneIndex     = 0;

            for (int i = 0; i < PedBoneArray.Length; i++)
            {
                Vector3 bonePosition = ped.GetBoneCoord(PedBoneArray[i]);
                float   boneDistance = bonePosition.DistanceTo(hitPosition);
                Bone    currentBone  = PedBoneArray[i];

                if (boneDistance < shortestBoneDistance)
                {
                    shortestBoneDistance = boneDistance;
                    nearestBoneIndex     = ped.GetBoneIndex(currentBone);
                }
            }

            return(nearestBoneIndex);
        }
Exemplo n.º 4
0
        public override bool OnCalloutAccepted()
        {
            karen = new Ped(spawnPoint);

            if (!karen.Exists())
            {
                return(false);
            }

            karenBlip = karen.AttachBlip();

            phone = new Rage.Object("prop_npc_phone", Vector3.Zero);

            if (phone.Exists())
            {
                phone.AttachTo(karen, karen.GetBoneIndex(PedBoneId.LeftHand), new Vector3(0.1490f, 0.0560f, -0.0100f), new Rotator(-17f, -142f, -151f));
            }
            karen.Tasks.PlayAnimation("cellphone@", "cellphone_photo_idle", 1.3f, AnimationFlags.Loop | AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask);

            karen.BlockPermanentEvents = true;

            //Ped[] nearbyPeds = karen.GetNearbyPeds(5);
            //Ped storeClerk = nearbyPeds.OrderBy(x => x.Position.DistanceTo(karen.Position)).FirstOrDefault();
            //karen.Tasks.AchieveHeading(MathHelper.ConvertDirectionToHeading(storeClerk.Direction - karen.Direction));


            Game.DisplaySubtitle("A gas station ~o~attendant~w~ reports a ~r~customer~w~ yelling in the store and refusing to leave", 10000);
            return(base.OnCalloutAccepted());
        }
        /// <summary>
        /// 車両を掴む処理
        /// </summary>
        /// <param name="player"></param>
        /// <param name="vehicle"></param>
        /// <param name="ofsetPosition"></param>
        private void Grip(Ped player, Vehicle vehicle, Vector3 ofsetPosition)
        {
            player.SetToRagdoll(0, 1);
            SetPlayerProof(true);
            _vehicle       = vehicle;
            _ofsetPosition = ofsetPosition;
            var forceToBreak = 99999.0f;
            var rotation     = new Vector3(0.0f, 0.0f, 0.0f);
            var isCollision  = true;

            Function.Call(Hash.ATTACH_ENTITY_TO_ENTITY_PHYSICALLY,
                          player,
                          vehicle,
                          player.GetBoneIndex(Bone.SKEL_R_Hand),
                          vehicle.GetBoneIndex("SKEL_ROOT"),
                          ofsetPosition.X,
                          ofsetPosition.Y,
                          ofsetPosition.Z,
                          0.0f,
                          0.0f,
                          0.0f,
                          rotation.X,
                          rotation.Y,
                          rotation.Z,
                          forceToBreak,
                          false, //?
                          false, //?
                          isCollision,
                          false, //?
                          2);    //?
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Start a looped particle on the specified ped.
        /// </summary>
        /// <param name="ped">The ped.</param>
        /// <param name="assetName">The name of the asset that holds the particle.</param>
        /// <param name="effectName">The name of the particle effect.</param>
        /// <param name="offset">The offset from the bone to play the effect.</param>
        /// <param name="rotation">The rotation of the particle.</param>
        /// <param name="bone">The bone to play the effect on.</param>
        /// <param name="scale">The scale of the particle.</param>
        /// <param name="xAxis"></param>
        /// <param name="yAxis"></param>
        /// <param name="zAxis"></param>
        /// <returns></returns>
        public static ParticleLooped StartLoopedParticle(this Ped ped, string assetName, string effectName,
                                                         Vector3 offset, Vector3 rotation, Bone bone, float scale,
                                                         bool xAxis = false, bool yAxis = false, bool zAxis = false)
        {
            var boneIndex = ped.GetBoneIndex(bone);

            Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, assetName);
            return(new ParticleLooped(Function.Call <int>(Hash.START_PARTICLE_FX_LOOPED_ON_PED_BONE, effectName,
                                                          ped.Handle,
                                                          offset.X, offset.Y, offset.Z, rotation.X, rotation.Y, rotation.Z, (int)bone, scale, xAxis, yAxis,
                                                          zAxis)));
        }
Exemplo n.º 7
0
 public LoopedParticle(string assetName, string particleName, Ped ped, PedBoneId bone, Vector3 offset, Rotator rotation, float scale)
 {
     AssetName    = assetName;
     ParticleName = particleName;
     LoadAsset();
     Handle = NativeFunction.Natives.StartParticleFxLoopedOnPedBone <uint>(particleName,
                                                                           ped,
                                                                           offset.X, offset.Y, offset.Z,
                                                                           rotation.Pitch, rotation.Roll, rotation.Yaw,
                                                                           ped.GetBoneIndex(bone),
                                                                           scale,
                                                                           false, false, false);
 }
Exemplo n.º 8
0
        private static Weapon Process(Weapon weaponOnBack, Ped ped)
        {
            var task = NativeFunction.Natives.GET_IS_TASK_ACTIVE <bool>(ped, 56);

            if (!task)
            {
                var currentWeapon       = ped.Inventory.EquippedWeapon;
                var currentWeaponObject = ped.Inventory.EquippedWeaponObject;
                if (currentWeapon != null && currentWeaponObject != null)
                {
                    if (acceptedWeapons.Contains((uint)currentWeapon.Hash))
                    {
                        if (weaponOnBack != null)
                        {
                            if (weaponOnBack.Asset.Hash == currentWeaponObject.Asset.Hash)
                            {
                                weaponOnBack.Delete();
                                weaponOnBack = null;
                            }
                        }
                        try
                        {
                            while (ped.Inventory.EquippedWeapon == currentWeapon)
                            {
                                GameFiber.Yield();
                            }
                        }
                        catch
                        {
                            return(weaponOnBack);
                        }
                        if (weaponOnBack != null)
                        {
                            weaponOnBack.Delete();
                            weaponOnBack = null;
                        }
                        weaponOnBack = new Weapon(currentWeapon.Asset, ped.Position, 30);
                        List <uint> componentHashes = GetComponentHashes((uint)currentWeapon.Hash, ped);
                        foreach (uint hash in componentHashes)
                        {
                            NativeFunction.Natives.GIVE_WEAPON_COMPONENT_TO_WEAPON_OBJECT(weaponOnBack, hash);
                        }
                        int tint = NativeFunction.Natives.GET_PED_WEAPON_TINT_INDEX <int>(ped, (uint)currentWeapon.Hash);
                        NativeFunction.Natives.SET_WEAPON_OBJECT_TINT_INDEX(weaponOnBack, tint);
                        weaponOnBack.AttachTo(ped, ped.GetBoneIndex(PedBoneId.Spine3), offsetPosition, Rotation);
                    }
                }
            }
            return(weaponOnBack);
        }
Exemplo n.º 9
0
        public static void MainMenuOnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index)
        {
            GameFiber.StartNew(delegate
            {
                if (selectedItem == AskFishingLicenseItem || selectedItem == AskHuntingLicenseItem)
                {
                    Ped closestPed = World.GetAllPeds().Where(x => x.IsAlive && x != Game.LocalPlayer.Character && x.IsHuman && !x.IsInAnyVehicle(false) && Vector3.Distance(x.Position, Game.LocalPlayer.Character.Position) < 12.5f).OrderBy(x => x.Position.DistanceTo(Game.LocalPlayer.Character.Position)).FirstOrDefault();
                    if (closestPed.Exists())
                    {
                        closestPed.Tasks.AchieveHeading(closestPed.GetHeadingTowards(Game.LocalPlayer.Character)).WaitForCompletion(2000);
                        Object id = new Object("hei_prop_hei_id_bank", Vector3.Zero);
                        closestPed.Tasks.PlayAnimation("mp_common", "givetake1_a", 2.5f, AnimationFlags.None);
                        id.AttachToEntity(closestPed, closestPed.GetBoneIndex(PedBoneId.RightPhHand), Vector3.Zero, new Rotator(0.0f, 180.0f, 0.0f));
                        GameFiber.Sleep(1200);
                        if (selectedItem == AskFishingLicenseItem)
                        {
                            WildernessCallouts.Common.FishingLicense(closestPed);
                        }
                        else if (selectedItem == AskHuntingLicenseItem)
                        {
                            WildernessCallouts.Common.HuntingLicense(closestPed);
                        }
                        id.Delete();
                        StaticPeds.Add(closestPed);
                    }
                }
                else if (selectedItem == CallAirAmbulanceItem)
                {
                    Ped pedToRescue      = WildernessCallouts.Common.GetPedToRescue();
                    AirParamedic airpara = new AirParamedic(pedToRescue, "You can leave, we will take care of him, thanks", "You can leave, we will take care of her, thanks");
                    airpara.Start();
                }
                else if (selectedItem == CallVetItem)
                {
                    Ped animal = WildernessCallouts.Common.GetValidAnimalForVetPickup();

                    Vet vet = new Vet(animal);
                    vet.Start();
                }
#if DEBUG
                else if (selectedItem == CreateEventItem)
                {
                    EventPool.CreateEvent();
                }
#endif
            });
        }
Exemplo n.º 10
0
        private static Weapon AIProcess(uint weapontoadd, Ped ped)
        {
            Weapon weaponOnBack = null;

            weaponOnBack = new Weapon(weapontoadd, ped.Position, 30);
            List <uint> aiComponentHashes = GetComponentHashes(weapontoadd, ped);

            foreach (uint hash in aiComponentHashes)
            {
                NativeFunction.Natives.GIVE_WEAPON_COMPONENT_TO_WEAPON_OBJECT(weaponOnBack, hash);
                //Game.LogTrivial($"Adding {hash} to weapon on back");
            }
            int tint = NativeFunction.Natives.GET_PED_WEAPON_TINT_INDEX <int>(ped, weapontoadd);

            NativeFunction.Natives.SET_WEAPON_OBJECT_TINT_INDEX(weaponOnBack, tint);
            weaponOnBack.AttachTo(ped, ped.GetBoneIndex(PedBoneId.Spine3), aiOffsetPosition, aiRotation);
            return(weaponOnBack);
        }
Exemplo n.º 11
0
        public static void MainMenuOnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index)
        {
            GameFiber.StartNew(delegate
            {
                if (selectedItem == AskFishingLicenseItem || selectedItem == AskHuntingLicenseItem)
                {
                    Ped closestPed = World.GetAllPeds().Where(x => x.IsAlive && x != Game.LocalPlayer.Character && x.IsHuman && !x.IsInAnyVehicle(false) && Vector3.Distance(x.Position, Game.LocalPlayer.Character.Position) < 12.5f).OrderBy(x => x.Position.DistanceTo(Game.LocalPlayer.Character.Position)).FirstOrDefault();
                    if (closestPed.Exists())
                    {
                        closestPed.Tasks.AchieveHeading(closestPed.GetHeadingTowards(Game.LocalPlayer.Character)).WaitForCompletion(2000);
                        Object id = new Object("hei_prop_hei_id_bank", Vector3.Zero);
                        closestPed.Tasks.PlayAnimation("mp_common", "givetake1_a", 2.5f, AnimationFlags.None);
                        id.AttachToEntity(closestPed, closestPed.GetBoneIndex(PedBoneId.RightPhHand), Vector3.Zero, new Rotator(0.0f, 180.0f, 0.0f));
                        GameFiber.Sleep(1200);
                        if (selectedItem == AskFishingLicenseItem)
                        {
                            WildernessCallouts.Common.FishingLicense(closestPed);
                        }
                        else if (selectedItem == AskHuntingLicenseItem)
                        {
                            WildernessCallouts.Common.HuntingLicense(closestPed);
                        }
                        id.Delete();
                        StaticPeds.Add(closestPed);
                    }
                }
                else if (selectedItem == CallAirAmbulanceItem)
                {
                    Ped pedToRescue      = World.GetAllPeds().Where(x => (x.IsDead || x.Health <= 20 || x == MissingPerson.CurrentMissingPed) && x != Game.LocalPlayer.Character && x.IsHuman && Vector3.Distance(x.Position, Game.LocalPlayer.Character.Position) < 15.0f && !AirParamedic.RescuedPeds.Contains(x)).OrderBy(x => x.Position.DistanceTo(Game.LocalPlayer.Character.Position)).FirstOrDefault();
                    AirParamedic airpara = new AirParamedic(pedToRescue, "You can leave, we will take care of him, thanks", "You can leave, we will take care of her, thanks");
                    airpara.Start();
                }
                else if (selectedItem == CallVetItem)
                {
                    Ped animal = WildernessCallouts.Common.GetClosestAnimal(Game.LocalPlayer.Character.Position, 30.0f);

                    int timesToLoop = 0;
                    while (timesToLoop < 20)
                    {
                        if (animal.Exists() && animal.IsDead && !Vet.TakenAnimals.Contains(animal))
                        {
                            break;
                        }
                        animal = WildernessCallouts.Common.GetClosestAnimal(Game.LocalPlayer.Character.Position, 35.0f);
                        timesToLoop++;
                    }           // Gets the closest dead animal
                    if (!animal.Exists() || animal.IsAlive || Vet.TakenAnimals.Contains(animal))
                    {
                        return;
                    }

                    Vet vet = new Vet(animal);
                    vet.Start();
                }
#if DEBUG
                else if (selectedItem == CreateEventItem)
                {
                    EventPool.CreateEvent();
                }
#endif
            });
        }
Exemplo n.º 12
0
        public void CreateScenario(int scenario)
        {
            GameFiber.StartNew(delegate
            {
                Logger.LogTrivial(this.GetType().Name, "Scenario: " + scenario);

                if (scenario == 1)     // SHOOT
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Shoot");
                    ped.Inventory.GiveNewWeapon(weaponAssets.GetRandomElement(true), 9999, true);

                    Vector3 posToShoot = ped.Position + (ped.ForwardVector * MathHelper.GetRandomSingle(1.5f, 8.0f)) + (ped.UpVector * MathHelper.GetRandomSingle(8.0f, 20.0f)) + (ped.RightVector * MathHelper.GetRandomSingle(-15.0f, 15.0f));
                    NativeFunction.CallByName <uint>("TASK_SHOOT_AT_COORD", ped, posToShoot.X, posToShoot.Y, posToShoot.Z, -1, (uint)Rage.FiringPattern.BurstFire);
                }
                else if (scenario == 2)     // PROTEST
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Protest");
                    ped.Tasks.PlayAnimation("special_ped@griff@monologue_1@monologue_1e", "iamnotaracist_4", 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                    pedObj = new Rage.Object("prop_cs_protest_sign_01", Vector3.Zero);
                    pedObj.AttachToEntity(ped, ped.GetBoneIndex(PedBoneId.RightPhHand), Vector3.Zero, Rotator.Zero);
                    GameFiber.StartNew(delegate
                    {
                        //GameFiber.StartNew(delegate
                        //{
                        //    while (!hasEnded && ped.Exists() && ped.IsAlive && !Functions.IsPedArrested(ped))
                        //    {
                        //        if (Vector3.Distance(Game.LocalPlayer.Character.Position, ped.Position) < 17.5f)
                        //        {
                        //            if (new Random().Next(0, 151) < 20)
                        //            {
                        //                string[] protestSpeeches = { "GENERIC_CURSE_MED", "GENERIC_CURSE_HIGH", "GENERIC_FUCK_YOU" };
                        //                ped.PlayAmbientSpeech(null, protestSpeeches[new Random().Next(protestSpeeches.Length)], 0, SpeechModifier.Force);
                        //            }
                        //            GameFiber.Sleep(2500);
                        //        }
                        //        GameFiber.Yield();
                        //    }
                        //});
                        GameFiber.Sleep(125);
                        while (ped.IsPlayingAnimation("special_ped@griff@monologue_1@monologue_1e", "iamnotaracist_4") && ped.IsPersistent)
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Detach();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Dismiss();
                        }
                    });
                }
                else if (scenario == 3)        // DRUNK NUDE GUY
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Drunk nude guy");
                    ped.SetMovementAnimationSet("move_m@drunk@verydrunk");
                    ped.Tasks.Wander();
                }
                else if (scenario == 4)     // GUITARRIST
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Guitarrist");

                    ped.Tasks.PlayAnimation("amb@world_human_musician@guitar@male@base", "base", 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                    pedObj = new Rage.Object(guitarModels.GetRandomElement(true), Vector3.Zero);
                    pedObj.AttachToEntity(ped, ped.GetBoneIndex(PedBoneId.LeftPhHand), Vector3.Zero, Rotator.Zero);
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (ped.IsPlayingAnimation("amb@world_human_musician@guitar@male@base", "base") && ped.IsPersistent)
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Detach();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Dismiss();
                        }
                    });
                }
                else if (scenario == 5)         // TOPLESS GIRL
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Topless girl");
                    ped.Tasks.PlayAnimation("amb@world_human_prostitute@hooker@base", "base", 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                }
                else if (scenario == 6)     // SUNBATHE
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Sunbathe");

                    AnimationDictionary maleAnimDict   = sunbatheMale.GetRandomElement(true);
                    AnimationDictionary femaleAnimDict = sunbatheFemale.GetRandomElement(true);

                    if (ped.IsMale)
                    {
                        ped.Tasks.PlayAnimation(maleAnimDict, "base", 2.0f, AnimationFlags.Loop);
                    }
                    else if (ped.IsFemale)
                    {
                        ped.Tasks.PlayAnimation(femaleAnimDict, "base", 2.0f, AnimationFlags.Loop);
                    }

                    ped.BlockPermanentEvents = true;

                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        if (ped.IsMale)
                        {
                            while (ped.IsPlayingAnimation(maleAnimDict, "base") && ped.IsPersistent)
                            {
                                GameFiber.Yield();
                            }
                            if (!hasEnded && ped.Exists())
                            {
                                ped.BlockPermanentEvents = false;
                            }
                        }
                        else if (ped.IsFemale)
                        {
                            while (ped.IsPlayingAnimation(femaleAnimDict, "base") && ped.IsPersistent)
                            {
                                GameFiber.Yield();
                            }
                            if (!hasEnded && ped.Exists())
                            {
                                ped.BlockPermanentEvents = false;
                            }
                        }
                    });
                }
                else if (scenario == 7)        // FREAK OUT GUY
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Freak out guy");

                    string animName = monkeyFreakOutAnimNames.GetRandomElement();
                    ped.Tasks.PlayAnimation("missfbi5ig_30monkeys", animName, 5.0f, AnimationFlags.Loop);
                    ped.BlockPermanentEvents = true;
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (ped.IsPlayingAnimation("missfbi5ig_30monkeys", animName) && ped.IsPersistent && ped.Exists())
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && ped.Exists())
                        {
                            ped.BlockPermanentEvents = false;
                        }
                    });
                }
                else if (scenario == 8)      // EPSILON
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Epsilon");

                    ped.Tasks.PlayAnimation("rcmepsilonism3", "ep_3_rcm_marnie_meditating", 2.0f, AnimationFlags.Loop);
                    ped.BlockPermanentEvents = true;
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (!hasEnded)
                        {
                            if (ped.Exists())
                            {
                                if (Vector3.Distance(Game.LocalPlayer.Character.Position, ped.Position) < 6.0f)
                                {
                                    if (ped.IsMale)
                                    {
                                        ped.PlayAmbientSpeech(epsilonVoicesMale.GetRandomElement(), "KIFFLOM_GREET", 0, SpeechModifier.Force);
                                    }
                                    else
                                    {
                                        ped.PlayAmbientSpeech(epsilonVoicesFemale.GetRandomElement(), "KIFFLOM_GREET", 0, SpeechModifier.Force);
                                    }
                                    break;
                                }
                            }
                            GameFiber.Yield();
                        }
                        if (!hasEnded && ped.Exists())
                        {
                            ped.BlockPermanentEvents = false;
                        }
                    });
                }
                else if (scenario == 9)     // BONGOS
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Bongos");

                    ped.Tasks.PlayAnimation("amb@world_human_musician@bongos@male@idle_a", "idle_a", 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                    pedObj = new Rage.Object(bongosModel, Vector3.Zero);
                    pedObj.AttachToEntity(ped, ped.GetBoneIndex(PedBoneId.LeftPhHand), Vector3.Zero, Rotator.Zero);
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (ped.IsPlayingAnimation("amb@world_human_musician@bongos@male@idle_a", "idle_a") && ped.IsPersistent && ped.Exists())
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Detach();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Dismiss();
                        }
                    });
                }
                else if (scenario == 10)     // BEGGER
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Begger");
                    string[] idles  = { "idle_a", "idle_b", "idle_c" };
                    string idleUsed = idles.GetRandomElement();
                    ped.Tasks.PlayAnimation("amb@world_human_bum_freeway@male@idle_a", idleUsed, 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                    pedObj = new Rage.Object(beggersSignModels.GetRandomElement(), Vector3.Zero);
                    pedObj.AttachToEntity(ped, ped.GetBoneIndex(PedBoneId.RightPhHand), Vector3.Zero, Rotator.Zero);
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(125);
                        while (ped.IsPlayingAnimation("amb@world_human_bum_freeway@male@idle_a", idleUsed) && ped.IsPersistent && ped.Exists())
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Detach();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Dismiss();
                        }
                    });
                }
                else if (scenario == 11)    // NUDE GIRL CHEERING
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Topless girl cheering");
                    char[] letters = { 'a', 'b', 'c', 'd' };
                    ped.Tasks.PlayAnimation("amb@world_human_cheering@female_" + letters.GetRandomElement(), "base", 5.0f, AnimationFlags.Loop);
                }
                else if (scenario == 12)     // Pushups
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Pushups");

                    Tuple <AnimationDictionary, string>[] anims  = { new Tuple <AnimationDictionary, string>("amb@world_human_push_ups@male@idle_a", "idle_d"), new Tuple <AnimationDictionary, string>("amb@world_human_push_ups@male@base", "base") };
                    Tuple <AnimationDictionary, string> animUsed = anims.GetRandomElement();

                    ped.Tasks.PlayAnimation(animUsed.Item1, animUsed.Item2, 2.0f, AnimationFlags.Loop);

                    ped.BlockPermanentEvents = true;

                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (ped.IsPlayingAnimation(animUsed.Item1, animUsed.Item2) && ped.IsPersistent && ped.Exists())
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && ped.Exists())
                        {
                            ped.BlockPermanentEvents = false;
                        }
                    });
                }
            });
        }
Exemplo n.º 13
0
 private void onTick(object sender, EventArgs e)
 {
     //Player character must not be in vehicle
     if (Game.Player.Character.IsOnFoot)
     {
         {
             //Select an NPC from an area around the player with a 2f radius
             foreach (var Vendor in World.GetNearbyPeds(Game.Player.Character.Position, 2f))
             {
                 //Existing
                 if (Vendor.Exists())
                 {
                     //NPC must be alive
                     if (Vendor.IsAlive)
                     {
                         //NPC must be a vendor
                         if (VendorModel.Contains(Vendor.Model))
                         {
                             //Show message with buy button (action button)
                             DisplayHelpTextThisFrame(MsgKey);
                             if (Game.IsControlJustPressed(2, GTA.Control.Context))
                             {
                                 //Displaying a "wanted" message
                                 if (Game.Player.WantedLevel > 0)
                                 {
                                     DisplayHelpTextThisFrame(MsgWanted);
                                     Wait(3000);
                                     return;
                                 }
                                 //Displaying a "money" message (if less 5)
                                 if (Game.Player.Money < 5)
                                 {
                                     DisplayHelpTextThisFrame(MsgMoney);
                                     Wait(3000);
                                     return;
                                 }
                                 //If everything is OK
                                 else
                                 {
                                     //Loading animation dictionary #1
                                     Function.Call(Hash.REQUEST_ANIM_DICT, "gestures@m@standing@casual");
                                 }
                                 Wait(5);
                                 //Loading animation dictionary #2
                                 Function.Call(Hash.REQUEST_ANIM_DICT, "mp_player_inteat@burger");
                                 Wait(5);
                                 //Playing conversation animation
                                 Function.Call(Hash.TASK_PLAY_ANIM, Game.Player.Character, "gestures@m@standing@casual", "gesture_you_soft", 8.0, 8.0 * -1, -1, 0, 0, false, false, false);
                                 //Waiting for animation #1 to end playback
                                 Wait(1000);
                                 //Stopping the animation task #1
                                 Function.Call(Hash.STOP_ANIM_TASK, Game.Player.Character, "gestures@m@standing@casual", "gesture_you_soft", 1.0);
                                 //The player is charged $5 to cook a hot dog
                                 Game.Player.Money = Game.Player.Money - 5;
                                 //Vendor cooks hot dog
                                 Wait(500);
                                 //Hot dog appears
                                 Hotdog = World.CreateProp("prop_cs_hotdog_01", Game.Player.Character.Position, true, true);
                                 //Current player character' fixation (1 of 3)
                                 Ped CurrentCharacter = Game.Player.Character;
                                 //The hot dog moves to the current character's hand
                                 Hotdog.AttachTo(CurrentCharacter, CurrentCharacter.GetBoneIndex(Bone.SKEL_L_Hand), new Vector3(0.2089f, 0.0662f, 0.0675f), new Vector3(151.4672f, 37.1995f, -145.3044f));
                                 //Playing eating animation
                                 Function.Call(Hash.TASK_PLAY_ANIM, Game.Player.Character, "mp_player_inteat@burger", "mp_player_int_eat_burger", 1.0, 1.0 * -1, -1, 0, 0, false, false, false);
                                 //Waiting for animation #2 to end playback
                                 Wait(2000);
                                 //Stopping the animation task #2
                                 Function.Call(Hash.STOP_ANIM_TASK, Game.Player.Character, "mp_player_inteat@burger", "mp_player_int_eat_burger", 1.0);
                                 Wait(5);
                                 //The hot dog disappears
                                 Hotdog.Delete();
                                 //The current player character' fixation ends
                                 CurrentCharacter.Delete();
                                 //Adding +5HP to player's character
                                 Game.Player.Character.Health = Game.Player.Character.Health + 5;
                                 //Pause before the purchase/wanted/money message appears (the cycle will start again)
                                 Wait(1000);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 14
0
        private void HandleGrapple()
        {
            if (IsGrappling)
            {
                if (!Exists(BatGrappleInstance))
                {
                    var prop = World.CreateProp(BatGrappleModel, Ped.Position + Vector3.RelativeTop * 100, false, false);

                    prop.FreezePosition = true;

                    prop.AttachTo(Ped, Ped.GetBoneIndex(Bone.SKEL_R_Hand), new Vector3(0.1f, 0f, 0), new Vector3(-90, 0, 0));

                    BatGrappleInstance = prop;
                }
            }
            else
            {
                if (Exists(BatGrappleInstance))
                {
                    BatGrappleInstance.Delete();
                }
            }

            if (!IsGrappling || Ped.IsRagdoll || IsGliding)
            {
                if (IsPlayingGrappleAnimation)
                {
                    ClearGrappleAnimation();
                }

                if (IsPlayingGrappleReelAnimation)
                {
                    ClearGrappleReelAnimation();
                }

                if (GrappleHook != null)
                {
                    GrappleHook.Delete();
                }

                if (IsGrappling)
                {
                    IsGrappling = false;
                }

                GrappleSpeed = 0f;

                return;
            }

            if (Exists(BatGrappleInstance) && BatGrappleInstance.IsAttachedTo(Ped))
            {
                Function.Call(Hash.PROCESS_ENTITY_ATTACHMENTS, Ped.Handle);
            }

            if (!IsPlayingGrappleAnimation)
            {
                Ped.Heading = (LastGrapplePoint - Ped.Position).ToHeading();

                StartGrappleTaskSequence();

                Ped.SetConfigFlag(60, true);

                IsPlayingGrappleAnimation = true;

                GrappleHook = new GrappleHook(LastGrapplePoint, this, BatGrappleInstance);
            }
            else
            {
                if (!GrappleHook.IsHooked)
                {
                    Ped.SetConfigFlag(60, true);

                    GrappleHook.Update();
                }
                else
                {
                    if (!IsPlayingGrappleReelAnimation)
                    {
                        var vel = Ped.Velocity;

                        Ped.Task.ClearAll();

                        Ped.Velocity = Vector3.Zero;

                        Ped.PlayAnimation("skydive@parachute@", "chute_idle", 8.0f, -8.0f, -1, AnimationFlags.Loop, 0.0f);

                        Ped.PlayAnimation("weapons@pistol_1h@", "aim_high_loop", 8.0f, -8.0f, -1, AnimationFlags.UpperBodyOnly | AnimationFlags.AllowRotation | AnimationFlags.StayInEndFrame, 0f);

                        Ped.SetAnimationSpeed("skydive@parachute@", "chute_idle", 0f);

                        Ped.SetAnimationSpeed("weapons@pistol_1h@", "aim_high_loop", 0f);

                        Ped.Velocity = vel;

                        Ped.SetConfigFlag(60, true);

                        IsPlayingGrappleReelAnimation = true;
                    }
                    else
                    {
                        var dirNormalized = (LastGrapplePoint - Ped.Position).Normalized;

                        Ped.SetConfigFlag(60, true);

                        if (Ped.HasCollidedWithAnything && Ped.Velocity.Length() > 5f)
                        {
                            var ray = World.Raycast(Ped.Position + (-LastGrappleWallNormal * 1.15f) + (Vector3.RelativeTop * 2f), Vector3.RelativeBottom, 5f, IntersectOptions.Map, Ped);

                            if (!ray.DitHitAnything)
                            {
                                var dir = Vector3.Reflect(dirNormalized, LastGrappleWallNormal);

                                Ped.Heading = dir.ToHeading();

                                Ped.Velocity = Ped.ForwardVector * 50;

                                IsGliding = true;

                                GlideHorizontalAdditive = new Vector3(0, -90, 0f);
                            }
                            else
                            {
                                Ped.Heading = (-LastGrappleWallNormal).ToHeading();

                                Ped.Task.ClearAll();

                                Ped.Velocity = Vector3.Zero;

                                Ped.Task.Climb();
                            }

                            IsGrappling = false;
                        }
                        else
                        {
                            Ped.Quaternion = Quaternion.FromToRotation(Ped.UpVector, dirNormalized) * Ped.Quaternion;

                            GrappleHook.Update();

                            GrappleSpeed = Mathf.Lerp(GrappleSpeed, 90f, Game.LastFrameTime * 2.5f);

                            Ped.Velocity = dirNormalized * GrappleSpeed;
                        }
                    }
                }
            }
        }