private void SpawnPedMoney(Ped targetPed)
        {
            if (targetPed.Money <= 0)
            {
                return;
            }

            if (Main.configRobPeople.Quick_Rob_People_No_Pickup)
            {
                Game.Player.Money += targetPed.Money;
                targetPed.Money    = 0;
                return;
            }

            string modelName = "prop_ld_wallet_01";

            if (targetPed.Gender == Gender.Female)
            {
                modelName = "prop_amb_handbag_01";
            }

            Model wallet = new Model(modelName);

            wallet.Request();
            while (!wallet.IsInCdImage)
            {
                Wait(1);
                wallet.Request();
            }

            World.CreateAmbientPickup(PickupType.MoneyPurse, targetPed.Position + targetPed.ForwardVector * 0.5f, wallet, targetPed.Money);
            wallet.MarkAsNoLongerNeeded();
        }
Esempio n. 2
0
        /* --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- */

        private IEnumerator Start()
        {
            while (Room.Loading)
            {
                yield return(null);
            }                                        // ?

            Model.Request(99);
            Model.Request(GetUsedModels());
            yield return(Model.LoadRequestedAsync());

            if (Player.Exist())
            {
                Player.Current.Position = overridePosition ? overrideStartPoint : transform.position;
            }
            else
            {
                new Player("Player", Personage.MAX_LEVEL / 2, 99, transform.position);
                Camera.AttachToPlayer();
            }
            overridePosition = false;

            SpawnEntities();

            Audio.PlayBackground(Background, BackgroundLoop);
            Player.Interface.Fade(FadeMode.Out);

            Player.Current.IsControllable = true;
            Player.Current.Immortal       = false;
            Calendar.Enable = true;
        }
Esempio n. 3
0
        internal static async Task Spawn()
        {
#if DEBUG
            if (!Game.PlayerPed.IsInVehicle())
            {
                var polModel = new Model((VehicleHash)Game.GenerateHash("sadot"));
                await polModel.Request(-1);

                Vehicle veh = await World.CreateVehicle(polModel, Game.PlayerPed.Position);

                polModel.MarkAsNoLongerNeeded();
                //veh.RegisterAsNetworked();
                Screen.ShowNotification($"network status {Function.Call<bool>(Hash.NETWORK_GET_ENTITY_IS_NETWORKED, veh)}");
                veh.SetExistOnAllMachines(true);
                await CitizenFX.Core.BaseScript.Delay(10000);

                CitizenFX.Core.Debug.WriteLine($"vehtonet: {API.VehToNet(veh.Handle)} getnetworkidfromentity: {API.NetworkGetNetworkIdFromEntity(veh.Handle)}");
                CitizenFX.Core.Debug.WriteLine($"ModelName: {veh.Model} DisplayName: {veh.DisplayName}");
                CitizenFX.Core.Debug.WriteLine($"Is this ELS Vehicle {veh.IsEls()}");
                if (veh == null)
                {
                    CitizenFX.Core.Debug.WriteLine("failure to spawn");
                    return;
                }
            }
            else //if (Game.PlayerPed.CurrentVehicle.IsEls())
            {
                Vehicle veh = Game.PlayerPed.CurrentVehicle;
                veh.RadioStation = RadioStation.RadioOff;
            }
            // Game.Player.Character.SetIntoVehicle(veh, VehicleSeat.Any);
#endif
        }
Esempio n. 4
0
        /// <summary>
        /// Equips this loadout with the specified options.
        /// </summary>
        /// <param name="taser">Whether or not to equip a TASER.</param>
        /// <param name="options">IPedCustomisables to set for the player.</param>
        public async void Equip(bool taser, IEnumerable <IPedCustomisable> options)
        {
            Model model = new Model(PedModelName);
            await model.Request(2000);

            if (model.IsLoaded)
            {
                await Game.Player.ChangeModel(model);

                foreach (IPedCustomisable pc in DefaultCustomisables)
                {
                    pc.SetPedCustomisable(Game.PlayerPed);
                    await BaseScript.Delay(50);
                }
                foreach (IPedCustomisable pc in options)
                {
                    pc.SetPedCustomisable(Game.PlayerPed);
                    await BaseScript.Delay(50);
                }

                Game.PlayerPed.Weapons.RemoveAll();
                foreach (WeaponHash hash in WeaponHashes)
                {
                    Game.PlayerPed.Weapons.Give(hash, -1, false, true);
                    await BaseScript.Delay(50);
                }
                if (taser)
                {
                    Game.PlayerPed.Weapons.Give(WeaponHash.StunGun, -1, false, true);
                }
            }
        }
Esempio n. 5
0
        public void Revert()
        {
            Game.MaxWantedLevel = this.playerOldMaxWantedLevel;
            Game.Player.Money   = 0;
            Model model = new Model(this.playerOldModel.Hash);

            model.Request(500);
            if (model.IsInCdImage && model.IsValid)
            {
                while (true)
                {
                    if (model.IsLoaded)
                    {
                        InputArgument[] arguments = new InputArgument[] { Game.Player, model.Hash };
                        Function.Call(Hash._0x00A1CADD00108836, arguments);
                        InputArgument[] argumentArray2 = new InputArgument[] { Game.Player.Character.Handle };
                        Function.Call(Hash._0x45EEE61580806D63, argumentArray2);
                        break;
                    }
                    Script.Wait(100);
                }
            }
            model.MarkAsNoLongerNeeded();
            Game.Player.Money = this.playerOldMoney;
            Game.Player.Character.Position = this.playerOldPosition;
            Game.Player.Character.Heading  = this.playerOldHeading;
            campFire.Delete();
        }
Esempio n. 6
0
        public async Task Update()
        {
            //Reload the prop.
            if (needsToReloadProp)
            {
                if (currentProp != null)
                {
                    Debug.WriteLine("Deleting: " + currentProp.Handle.ToString());
                    currentProp.Delete();
                }

                //Check if we need to load the new model.
                if (!currentPropModel.IsLoaded)
                {
                    await currentPropModel.Request(500);
                }

                currentProp = await World.CreateProp(currentPropModel, Vector3.Zero, Vector3.Zero, false, false);

                Debug.WriteLine("New: " + currentProp.Handle.ToString());
                needsToReloadProp = false;
            }

            //Apply behavior.
            switch (behavior)
            {
            case SelectionBehavior.PlaceOnSurface:
                //PlaceCurrentPropOnGround(Vector3.Zero); //@TODO(bma): Implement this properly, this requires input/freecam probably.
                break;

            case SelectionBehavior.PlaceInfrontOfCamera:
                PlaceCurrentPropInfrontOfCamera();
                break;
            }
        }
Esempio n. 7
0
        public Vehicle CreateVehicle(Model model, Vector3 position, Vector3 rotation, int netHash)
        {
            if (model == null || !model.IsValid || !model.IsInCdImage)
            {
                return(null);
            }
            LogManager.DebugLog("CREATING VEHICLE FOR NETHASH " + netHash);
            model.Request(10000);
            LogManager.DebugLog("LOAD COMPLETE. AVAILABLE: " + model.IsLoaded);

            var veh = World.CreateVehicle(model, position, rotation.Z);

            LogManager.DebugLog("VEHICLE CREATED. NULL? " + (veh == null));
            veh.Rotation     = rotation;
            veh.IsInvincible = true;
            LogManager.DebugLog("PROPERTIES SET");
            lock (HandleMap)
            {
                if (!HandleMap.Reverse.ContainsKey(veh.Handle))
                {
                    HandleMap.Reverse.Add(veh.Handle, netHash);
                }
            }
            LogManager.DebugLog("DISCARDING MODEL");
            model.MarkAsNoLongerNeeded();
            LogManager.DebugLog("CREATEVEHICLE COMPLETE");
            return(veh);
        }
Esempio n. 8
0
        public static Prop SpawnAttachedProp(Vehicle vehicle, string modelName, string bone, Vector3 rotation)
        {
            Model model = new Model(modelName);

            model.Request();

            if (!model.IsInCdImage || !model.IsValid)
            {
                return(null);
            }

            while (!model.IsLoaded)
            {
                Script.Yield();
            }

            if (!model.IsLoaded)
            {
                return(null);
            }

            Prop    prop   = World.CreateProp(model, Vector3.Zero, false, false);
            Vector3 offset = vehicle.GetPositionOffset(vehicle.Bones[bone].Position);

            if (bone == "")
            {
                offset = Vector3.Zero;
            }

            prop.AttachTo(vehicle, offset, Vector3.Zero);

            return(prop);
        }
Esempio n. 9
0
        public void GenerateNeighbors()
        {
            if (!CanUpdate)
            {
                return;
            }

            _tiles = new Entity[_dimensions * 2 + 1, _dimensions * 2 + 1];
            for (var i = -_dimensions; i <= _dimensions; i++)
            {
                for (var j = -_dimensions; j <= _dimensions; j++)
                {
                    if (!Model.IsLoaded)
                    {
                        Model.Request();
                        while (!Model.IsLoaded)
                        {
                            Script.Yield();
                        }
                    }
                    var pos = Position + new Vector3(i, j, 0) * _tileSize;
                    var obj = World.CreateProp(Model, pos, Vector3.Zero, false, false) ?? new Prop(0);
                    obj.FreezePosition   = true;
                    obj.Quaternion       = Quaternion;
                    obj.PositionNoOffset = pos;
                    _tiles[i + _dimensions, j + _dimensions] = obj;
                }
            }
            LastTile = this;
        }
Esempio n. 10
0
        public static void SpawnVehicle(string vehiclename)
        {
            Model model = new Model(vehiclename);

            model.Request(1000);
            World.CreateVehicle(model, Game.Player.Character.Position + Game.Player.Character.ForwardVector * 5);
        }
        public async Task LoadDefaultModel(bool LoadMale)
        {
            PedHash CharacterModel;

            if (LoadMale)
            {
                CharacterModel = PedHash.FreemodeMale01;
            }
            else
            {
                CharacterModel = PedHash.FreemodeFemale01;
            }

            Model characterModel = new Model(CharacterModel);

            characterModel.Request(500);

            if (characterModel.IsInCdImage && characterModel.IsValid)
            {
                while (!characterModel.IsLoaded)
                {
                    await BaseScript.Delay(0);
                }

                Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, characterModel.Hash);
                Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);
            }

            characterModel.MarkAsNoLongerNeeded();
        }
Esempio n. 12
0
        public static Vector3 GetSpawnPoint(float distanceFromPlayer)
        {
            try
            {
                Script.Wait(100);
                Model m = new Model(VehicleHash.Panto);
                m.Request(2000);

                var v = World.CreateVehicle(m, Game.Player.Character.Position.Around(distanceFromPlayer));
                Script.Wait(100);
                try
                {
                    if (v != null)
                        v.PlaceOnNextStreet();
                }
                catch (Exception ex)
                {
                    RPGLog.Log(ex);
                }

                var pos = v != null ? v.Position : Game.Player.Character.Position.Around(distanceFromPlayer);
                if (v != null) v.Delete();
                return pos;
            }
            catch(Exception ex)
            {
                RPGLog.Log(ex);
                throw;
            }
        }
Esempio n. 13
0
        public static void LoadModel(Model model)
        {
            if (!model.IsValid)
            {
                return;
            }

            LogManager.DebugLog("REQUESTING MODEL " + model.Hash);
            ModelRequest = true;
            DateTime start = DateTime.Now;

            while (!model.IsLoaded)
            {
                model.Request();
                //Function.Call(Hash.REQUEST_COLLISION_FOR_MODEL, model.Hash);
                Script.Yield();

                if (DateTime.Now.Subtract(start).TotalMilliseconds > 1000)
                {
                    break;
                }
            }
            ModelRequest = false;
            LogManager.DebugLog("MODEL REQUESTED: " + model.IsLoaded);
        }
Esempio n. 14
0
File: Enemy.cs Progetto: Guad/NOOSE
        public Enemy(Vector3 position, float heading)
        {
            var tmpMod  = new Model(_skins[Dice.Next(_skins.Length)]);
            int counter = 0;

            do
            {
                tmpMod.Request();
                Script.Yield();
                counter++;
            } while (!tmpMod.IsLoaded && counter < 10000);
            int c2 = 0;

            do
            {
                Character = Function.Call <Ped>(Hash.CREATE_PED, 26, tmpMod.Hash, position.X, position.Y, position.Z, heading, false, false);
                c2++;
            } while (Character == null && c2 < 3000);
            Character.Accuracy = Dice.Next(30, 100);
            Character.Weapons.Give(_guns[Dice.Next(_guns.Length)], 200, true, true);
            var relation  = EnemyGroup;
            var relation2 = Game.Player.Character.RelationshipGroup;

            World.SetRelationshipBetweenGroups(Relationship.Hate, relation, relation2);
            World.SetRelationshipBetweenGroups(Relationship.Hate, relation2, relation);
            Character.RelationshipGroup = relation;
        }
Esempio n. 15
0
        public static void SetPlayerSkin(PedHash skin)
        {
            var PlayerChar = Game.Player.Character;
            var health     = PlayerChar.Health;
            var model      = new Model(skin);

            ModelRequest = true;
            model.Request(1000);

            if (model.IsInCdImage && model.IsValid)
            {
                while (!model.IsLoaded)
                {
                    Script.Yield();
                }

                Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, model.Hash);
                Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, PlayerChar);
            }
            PlayerChar   = Game.Player.Character;
            ModelRequest = false;
            //model.MarkAsNoLongerNeeded();

            PlayerChar.MaxHealth = 200;
            PlayerChar.Health    = health;
        }
Esempio n. 16
0
        public Teammate(Vector3 spawnpoint)
        {
            World.SetRelationshipBetweenGroups(Relationship.Respect, NOOSEGroup, Game.Player.Character.RelationshipGroup);

            World.SetRelationshipBetweenGroups(Relationship.Hate, NOOSEGroup, Enemy.EnemyGroup);
            World.SetRelationshipBetweenGroups(Relationship.Hate, Enemy.EnemyGroup, NOOSEGroup);


            var swatmodel = new Model(PedHash.Swat01SMY);
            int counter   = 0;

            do
            {
                swatmodel.Request();
                Script.Yield();
                counter++;
            } while (!swatmodel.IsLoaded && counter < 10000);

            Character                       = Function.Call <Ped>(Hash.CREATE_PED, 26, swatmodel.Hash, spawnpoint.X, spawnpoint.Y, spawnpoint.Z, 0f, false, false);
            Character.Health                = 200;
            Character.Armor                 = 200;
            Character.RelationshipGroup     = NOOSEGroup;
            Character.AlwaysDiesOnLowHealth = false;
            Function.Call(Hash.REMOVE_PED_FROM_GROUP, Character.Handle);
            Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, Character.Handle, Function.Call <int>(Hash.GET_PED_GROUP_INDEX, Game.Player.Character.Handle));
        }
Esempio n. 17
0
        public override bool Run(string[] inputParams)
        {
            PedHash pedHash = PedHash.Abigail;

            if (!Enum.TryParse <PedHash>(inputParams[1], out pedHash))
            {
                return(false);
            }

            Model characterModel = new Model(pedHash);

            characterModel.Request(500);

            if (characterModel.IsInCdImage && characterModel.IsValid)
            {
                while (!characterModel.IsLoaded)
                {
                    Script.Wait(100);
                }

                Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, characterModel.Hash);
                Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);
            }

            characterModel.MarkAsNoLongerNeeded();
            return(true);
        }
Esempio n. 18
0
        private static void Reinforcement(Skill skill)
        {
            SkillEventHandler.Do(x =>
            {
                var crewSize       = skill.GetIntParam("Crew Size");
                var crewHp         = skill.GetIntParam("Member HP");
                var crewWeapon     = skill.GetStringParam("Weapon");
                var crewWeaponEnum = (WeaponHash)Enum.Parse(typeof(WeaponHash), crewWeapon);

                for (int i = 0; i < crewSize; i++)
                {
                    Model model = PedHash.Security01SMM;
                    model.Request(1000);
                    var ped = World.CreatePed(model, new Vector3(Game.Player.Character.Position.X + 0.5f, Game.Player.Character.Position.Y + 0.5f, Game.Player.Character.Position.Z + 0.5f) + Vector3.RandomXY());
                    RPG.WorldData.AddPed(new NpcObject("ReinforcementsPed_" + i, ped));
                    ped.RelationshipGroup = Game.Player.Character.RelationshipGroup;
                    ped.Health            = crewHp;
                    if (crewHp > 20)
                    {
                        ped.Armor = 20;
                    }
                    ped.Weapons.Give(crewWeaponEnum, 1000, true, true);
                    ped.CanSwitchWeapons = true;
                }
            });
        }
        private async Task SetNewCurrentProp()
        {
            Profiler.Enter("BuilderObjectManager_Update_SetNewCurrentProp");

            //Unload and destroy the current prop and model.
            if (currentProp != null && currentProp.Exists())
            {
                Model propModel = currentProp.Model;
                propModel.MarkAsNoLongerNeeded();

                currentProp.Delete();
            }

            //Check if we need to load the new model.
            if (!modelToLoad.IsLoaded)
            {
                await modelToLoad.Request(500);
            }

            currentProp = await World.CreateProp(modelToLoad, Vector3.Zero, Vector3.Zero, false, false);

            isPropLoaded = true;

            Profiler.Exit();
        }
Esempio n. 20
0
        private async Task OnSpawnVehicle(string modelName)
        {
            //TODO: Check if the model is actually a valid model.
            Model vehModel    = new Model(modelName);
            bool  modelLoaded = await vehModel.Request(1000);

            if (!modelLoaded)
            {
                ChatHelper.SendMessage("DevToolbox", $"Failed to load model {modelName}", 255, 0, 0);
                return;
            }

            Player player = new Player(PlayerId());

            Vector3 vehPosition = player.Character.Position;
            float   vehHeading  = player.Character.Heading;

            Vehicle vehToSpawn = await World.CreateVehicle(vehModel, vehPosition, vehHeading);

            Debug.WriteLine(vehToSpawn.Handle.ToString());
            player.Character.SetIntoVehicle(vehToSpawn, VehicleSeat.Driver);

            ChatHelper.SendMessage("DevToolbox", "Successfully spawned vehicle", 0, 255, 0);

            DevToolboxState state = RaceClient.Instance.States.GetState <DevToolboxState>();

            state.CarModel.Unset();
        }
Esempio n. 21
0
        public static Vector3 GetSpawnPoint(float distanceFromPlayer)
        {
            try
            {
                Script.Wait(100);
                Model m = new Model(VehicleHash.Panto);
                m.Request(2000);

                var v = World.CreateVehicle(m, Game.Player.Character.Position.Around(distanceFromPlayer));
                Script.Wait(100);
                try
                {
                    if (v != null)
                    {
                        v.PlaceOnNextStreet();
                    }
                }
                catch (Exception ex)
                {
                    RPGLog.Log(ex);
                }

                var pos = v != null ? v.Position : Game.Player.Character.Position.Around(distanceFromPlayer);
                if (v != null)
                {
                    v.Delete();
                }
                return(pos);
            }
            catch (Exception ex)
            {
                RPGLog.Log(ex);
                throw;
            }
        }
Esempio n. 22
0
 public static void SpawnVehicle(string vehiclename, Vector3 pos)
 {
     Model model = new Model(vehiclename);
     model.Request(1000);
     var veh = Function.Call<Vehicle>((Hash)0xAF35D0D2583051B0, model.Hash, pos.X, pos.Y, pos.Z, Game.Player.Character.Heading, 0, 0);
     Function.Call(Hash.SET_PED_INTO_VEHICLE, Game.Player.Character.Handle, veh.Handle, -1);
 }
Esempio n. 23
0
    public void Handle (TMessageInternal message)
    {
      if (message.NotNull ()) {
        if (message.IsModule (TResource.TModule.Factory)) {
          // from child only
          if (message.Node.IsRelationChild) {
            if (message.IsAction (TInternalMessageAction.DatabaseRequest)) {
              var authentication = message.Support.Argument.Types.Authentication;

              // to sibiling
              var messageInternal = new TFactoryMessageInternal (TInternalMessageAction.DatabaseResponse, authentication, TypeInfo);
              messageInternal.Node.SelectRelationParent (TChild.Front);
              messageInternal.Support.Argument.Types.ConnectionData.CopyFrom (Model.Request (authentication));

              DelegateCommand.PublishInternalMessage.Execute (messageInternal);
            }

            if (message.IsAction (TInternalMessageAction.Change)) {
              // to module
              var messageModule = new TFactoryMessage (TMessageAction.Changed, TypeInfo);
              messageModule.Support.Argument.Types.ConnectionData.CopyFrom (message.Support.Argument.Types.ConnectionData);

              DelegateCommand.PublishMessage.Execute (messageModule);
            }
          }
        }
      }
    }
Esempio n. 24
0
        private static void GeneratePersonalVehicleAndBlip(string playerName, VehicleDefinition vehicleDefinition, Vector4 spawnPoint)
        {
            Model model = new Model(vehicleDefinition.VehicleName).Hash;

            model.Request();
            while (!model.IsLoaded)
            {
                Script.Yield();
            }
            _personalVehicle = World.CreateVehicle(vehicleDefinition.VehicleName, new Vector3(spawnPoint.X, spawnPoint.Y, spawnPoint.Z), spawnPoint.H);
            if (_personalVehicle == null)
            {
                Logger.Log("GeneratePersonalVehicleAndBlip(): World.CreateVehicle() failed to create a vehicle, which should never happen.");
                return;
            }
            _personalVehicle.PlaceOnGround();
            ConfigurePersonalVehicle(_personalVehicle, vehicleDefinition);
            _personalVehicle.LockStatus = VehicleLockStatus.Locked;
            _personalVehicle.PreviouslyOwnedByPlayer = true;
            Logger.Log("GeneratePersonalVehicleAndBlip(): placed a " + _personalVehicle.PrimaryColor + " "
                       + (VehicleHash)_personalVehicle.Model.Hash + " at ("
                       + Math.Round(spawnPoint.X, 3) + ", "
                       + Math.Round(spawnPoint.Y, 3) + ", "
                       + Math.Round(spawnPoint.Z, 3) + ")");
            _personalVehicleBlip        = _personalVehicle.AddBlip();
            _personalVehicleBlip.Sprite = BlipSprite.PersonalVehicleCar;
            _personalVehicleBlip.Name   = vehicleDefinition.VehicleName;
            _personalVehicleBlip.Scale  = 0.8888f;
            PlayerBlipColors colorToUse = (PlayerBlipColors)System.Enum.Parse(typeof(PlayerBlipColors), playerName);

            Function.Call(Hash.SET_BLIP_COLOUR, _personalVehicleBlip, (int)colorToUse);
        }
Esempio n. 25
0
    public void ChangePlayerModel(PedHash hash)
    {
        var model = new Model(hash);

        // only in recent script hook

        /*
         * if (!Game.Player.ChangeModel(model))
         * {
         *  UI.Notify("could not request model");
         * }
         */
        if (!model.IsInCdImage || !model.IsPed || !model.Request(1000))
        {
            UI.Notify("could not request model");
        }
        else
        {
            Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, model.Hash);
            Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);
            if (hash == PedHash.FreemodeMale01 || hash == PedHash.FreemodeFemale01)
            {
                // must call SET_PED_HEAD_BLEND_DATA otherwise head overlays don't work
                var slot_key   = new SlotKey(SlotType.Parent, 0);
                var slot_value = new SlotValue(0, 0, 4, 4);
                var ped        = Game.Player.Character;
                SetSlotValue(ped, slot_key, slot_value);
            }
            data.Clear();
        }
        model.MarkAsNoLongerNeeded();
    }
Esempio n. 26
0
        private void CreateColonel()
        {
            _colonel?.Delete(); // in case the colonel already exists somehow.
            var m = new Model(PedHash.Marine01SMM);

            m.Request();
            while (!m.IsLoaded)
            {
                Script.Yield();
            }
            _colonel = World.CreatePed(m, _colonelSpawn - Vector3.WorldUp, _colonelHeading);
            if (_colonel == null)
            {
                // Let's break here just in case.
                throw new NullReferenceException("Colonel returned null for IntroMission.");
            }
            var b = _colonel.AddBlip();

            b.Sprite = BlipSprite.GTAOMission;
            b.Color  = Scene.MarkerBlipColor;
            b.Name   = "Colonel Larson";
            _colonel.SetDefaultClothes();
            _colonel.RelationshipGroup = PlayerPed.RelationshipGroup;
            _colonel.CanRagdoll        = false;
            m.MarkAsNoLongerNeeded();
        }
Esempio n. 27
0
        private void CreatePeds()
        {
            Script.Yield();
            var model = new Model(PedHash.Pilot02SMM);

            model.Request();
            while (!model.IsLoaded)
            {
                Script.Yield();
            }
            var ped = World.CreatePed(model, new Vector3(-6543.132f, -1331.071f, 29.23944f), 283.5533f);

            ped.TaskStartScenarioInPlace("world_human_smoking");
            ped.SetDefaultClothes();
            var b = ped.AddBlip();

            b.Sprite       = BlipSprite.Helicopter;
            b.Name         = "NASA Heli Transport";
            b.IsShortRange = true;
            b.Color        = Scene.MarkerBlipColor;
            _pilots.Add(new Pilot(ped.Handle, new Vector3(-1163.048f, -1713.792f, 4.236674f), 137.986f));

            var ped2 = World.CreatePed(model, new Vector3(-1165.701f, -1715.857f, 3.237385f), 306.5582f);

            ped2.SetDefaultClothes();
            ped2.TaskStartScenarioInPlace("world_human_guard_stand");
            var b2 = ped2.AddBlip();

            b2.Sprite       = BlipSprite.Helicopter;
            b2.Name         = "NASA Heli Transport";
            b2.IsShortRange = true;
            b2.Color        = Scene.MarkerBlipColor;
            _pilots.Add(new Pilot(ped2.Handle, new Vector3(-6540.545f, -1329.75f, 30.23945f), 128.9673f));
        }
Esempio n. 28
0
        public void StartEntry(int entryPoint, Ped[] team)
        {
            var entry = _entryData[entryPoint];

            switch (entry.Type)
            {
            case EntryTypes.Teleport:
                foreach (var ped in team)
                {
                    ped.Position = entry.Position;
                    ped.Heading  = entry.Heading;
                }
                break;

            case EntryTypes.Rappel:
                if (team.Length == 1)
                {
                    var rappel = new RappelEntry(entry.Helipads[0], entry.Position);
                    rappel.AddPassenger(team[0]);
                    _rappelUpdates.Add(rappel);
                }
                else
                {
                    var rappel = new RappelEntry(entry.Helipads[0], entry.Position);
                    foreach (Ped ped in team)
                    {
                        rappel.AddPassenger(ped);
                    }
                    _rappelUpdates.Add(rappel);
                }
                break;

            case EntryTypes.Plane:
                _planeEntry = new PlaneEntry(entry.PlaneSpawn, entry.PlaneSpawnHeading, entry.Approach, entry.RunwayStart, entry.RunwayEnd);
                foreach (Ped ped in team)
                {
                    _planeEntry.AddPassenger(ped);
                }
                _planeEntry.Start();
                break;
            }
            foreach (var source in _decorativeVehicles.Where(x => x.EntryPoint == entryPoint))
            {
                var tmpMod  = new Model(source.Model);
                int counter = 0;
                do
                {
                    tmpMod.Request();
                    Script.Yield();
                    counter++;
                } while (!tmpMod.IsLoaded && counter < 10000);
                var tmpVeh = Function.Call <Vehicle>(Hash.CREATE_VEHICLE, tmpMod.Hash, source.Position.X, source.Position.Y, source.Position.Z, source.Heading, false, false);
                tmpVeh.SirenActive = source.SirenActive;
                foreach (VehicleDoor door in source.OpenDoors)
                {
                    tmpVeh.OpenDoor(door, false, false);
                }
                CleanupBag.Add(tmpVeh);
            }
        }
Esempio n. 29
0
        private async void LoadDefaultSkin()
        {
            Trainer.DebugLine($"Changing to default skin {Config["DefaultSkin"]}.");
            var skin = new Model(Config["DefaultSkin"]);

            skin.Request();

            while (!skin.IsLoaded)
            {
                Trainer.DebugLine("Waiting for skin to load.");
                await BaseScript.Delay(100);
            }

            var playerPed = Game.PlayerPed;

            if (skin == playerPed.Model)
            {
                Trainer.DebugLine("Same as current skin. Doing nothing.");
            }
            else
            {
                Trainer.DebugLine("Changing skin...");
                justRunSpawnHandler = true;
                await ChangePlayerSkin(playerPed, skin);

                Config["CurrentSkin"] = Config["DefaultSkin"];
                Trainer.DebugLine("Skin changed!");
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Setup fighter for the AI player.
        /// </summary>
        public void Setup()
        {
            var pedModel = new Model(PedHash.Pilot02SMM);

            var vehModel = new Model(new VehicleHash[] {
                VehicleHash.Lazer,
                VehicleHash.Besra,
                VehicleHash.Hydra
            }.GetRandomItem());

            var spawnPos = Scripts.GetValidSpawnPos(Team.JetSpawnPoint.Position);

            if (!pedModel.IsLoaded)
            {
                pedModel.Request(1000);
            }

            if (!vehModel.IsLoaded)
            {
                vehModel.Request(1000);
            }

            var vehicle = new ManageableVehicle(World.CreateVehicle(vehModel, spawnPos));

            vehicle.LodDistance           = 2000;
            vehicle.Heading               = Team.JetSpawnPoint.Heading;
            vehicle.Vehicle.EngineRunning = true;
            Function.Call(Hash.SET_VEHICLE_EXPLODES_ON_HIGH_EXPLOSION_DAMAGE, vehicle.Handle, true);

            vehicle.Vehicle.BodyHealth = 0.01f;
            vehicle.MaxHealth          = MaxHealth;

            vehicle.LandingGearState = LandingGearState.Retracted;

            var blip = vehicle.AddBlip();

            blip.Sprite = BlipSprite.Jet;
            blip.Scale  = 0.8f;
            blip.Alpha  = 220;

            Function.Call(Hash.SET_BLIP_SECONDARY_COLOUR, blip.Handle, Team.Color.R, Team.Color.G, Team.Color.B);
            Function.Call((Hash)0xB81656BC81FE24D1, blip.Handle, 1);

            ManagedVehicle = vehicle;

            var ped = new ManageablePed(World.CreatePed(pedModel, spawnPos));

            ped.Ped.RelationshipGroup = Team.RelationshipGroup;

            ped.Ped.SetIntoVehicle(vehicle.Vehicle, VehicleSeat.Driver);

            Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, ped.Handle, 1, 1);
            Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, ped.Handle, 52, 0);
            Function.Call(Hash.SET_PED_CAN_SWITCH_WEAPON, ped.Ped.Handle, false);

            ManagedPed = ped;

            losChecker.Enabled = true;
        }
Esempio n. 31
0
        public static Model GetRandomVehicleModel()
        {
            Model model = default(Model);

            model = new Model(VehicleModels[Random.Next(VehicleModels.Length)]);
            //model._002Ector(VehicleModels[Random.Next(VehicleModels.Length)]);
            return(model.Request(1500) ? model : null);
        }
Esempio n. 32
0
        public void Start()
        {
            var spawnRegion = new Vector3(-9946.63f, -10148.71f, 1000.36f);
            var random      = new Random();

            for (var i = 0; i < 15; i++)
            {
                var randDist   = Function.Call <float>(Hash.GET_RANDOM_FLOAT_IN_RANGE, 20f, 100f);
                var spawnPoint = spawnRegion.Around(randDist);
                var ground     = World.GetGroundHeight(spawnPoint + Vector3.WorldUp);
                if (ground == 0)
                {
                    continue;
                }
                var ped = GtsLibNet.CreateAlien(null, spawnPoint, random.Next(135, 220));
                ped.Position = new Vector3(ped.Position.X, ped.Position.Y, ground);
                ped.Weapons.Give((WeaponHash)Game.GenerateHash("weapon_pulserifle"), 15, true, true);
                ped.AddBlip();
                ped.IsOnlyDamagedByPlayer = true;
                _hostiles.Add(ped);
                Script.Yield();
            }

            var ufoModel = new Model("zanufo");

            ufoModel.Request();
            while (!ufoModel.IsLoaded)
            {
                Script.Yield();
            }
            for (var i = 0; i < 4; i++)
            {
                var randDist   = Function.Call <float>(Hash.GET_RANDOM_FLOAT_IN_RANGE, 40f, 145f);
                var spawnPoint = spawnRegion.Around(randDist);
                var vehicle    = World.CreateVehicle(ufoModel, spawnPoint);
                vehicle.PlaceOnGround();
                vehicle.IsOnlyDamagedByPlayer = true;
                var pedModel = (Model)GtsLibNet.GetAlienModel();
                pedModel.Request();
                while (!pedModel.IsLoaded)
                {
                    Script.Yield();
                }
                var ped = vehicle.CreatePedOnSeat(VehicleSeat.Driver, pedModel);
                var b   = ped.AddBlip();
                b.Sprite = (BlipSprite)422;
                b.Name   = "UFO";
                ped.IsOnlyDamagedByPlayer = true;
                Function.Call(Hash.SET_CURRENT_PED_VEHICLE_WEAPON, ped,
                              Game.GenerateHash("VEHICLE_WEAPON_PLAYER_LAZER"));
                GtsLibNet.GivePedAlienAttributes(ped);
                pedModel.MarkAsNoLongerNeeded();
                _hostiles.Add(ped);
                _ufos.Add(vehicle);
                Script.Yield();
            }
            ufoModel.MarkAsNoLongerNeeded();
        }
Esempio n. 33
0
		public static Model RequestModel(int hash, int limit = 1000)
		{
			var tmpModel = new Model(hash);
			int counter = 0;
			while (!tmpModel.IsLoaded && counter < limit)
			{
				tmpModel.Request();
				Script.Yield();
				counter++;
			}
			return tmpModel;
		}
Esempio n. 34
0
        private static int Create(Vector3 position, Vector3 rotation)
        {
            var model = new Model("prop_ld_bomb_01");
            if (!model.IsLoaded)
                model.Request(1000);

            var mBomb = World.CreateProp(model, position, false, false);
            Function.Call(Hash.SET_ENTITY_RECORDS_COLLISIONS, mBomb.Handle, true);
            Function.Call(Hash.SET_ENTITY_LOAD_COLLISION_FLAG, mBomb.Handle, true);
            Function.Call(Hash.SET_ENTITY_LOD_DIST, mBomb.Handle, 1000);
            mBomb.Rotation = rotation;
            return mBomb.Handle;
        }
Esempio n. 35
0
        /// <summary>
        /// Setup fighter for the local player.
        /// </summary>
        public void Setup()
        {
            var vehModel = new Model(VehicleHash.Lazer);

            if (!vehModel.IsLoaded)
                vehModel.Request(1000);

            //Create the vehicle
            var vehicle = new ManageableVehicle(World.CreateVehicle(vehModel, Team.JetSpawnPoint.Position));
            vehicle.Heading = Team.JetSpawnPoint.Heading;

            vehicle.Vehicle.EngineRunning = true;
            vehicle.IsInvincible = true;
            vehicle.MaxSpeed = 110;
            ManagedVehicle = vehicle;
            ManagedVehicle.EnterWater += EnterWater;

            irFlares = new IRFlareManager();

            irFlares.SetupWithVehicle(ManagedVehicle.Vehicle);

            //Handle the ped
            var ped = new ManageablePed(Game.Player.Character);
            ped.Ped.RelationshipGroup = Team.RelationshipGroup;
            ped.Ped.SetIntoVehicle(vehicle.Vehicle, VehicleSeat.Driver);
            ped.IsInvincible = true;

            ManagedPed = ped;
            ManagedPed.ExitVehicle += ExitVehicle;

            interpCam = new InterpolatingCamera(vehicle.GetOffsetInWorldCoords(new Vector3(-2f, -2f, 10f)));
            interpCam.MainCamera.PointAt(vehicle);
            interpCam.Start();

            engineFX1 = new LoopedPTFX("core", "ent_sht_extinguisher");
            engineSound = new GameSound("SPRAY", "CARWASH_SOUNDS");

            boostTimer.Start();
        }
Esempio n. 36
0
        public RappelEntry(Vector3 helipad, Vector3 target)
        {
            _target = target;
            int counter = 0;
            var mav = new Model(VehicleHash.Polmav);
            do
            {
                mav.Request();
                Script.Yield();
                counter++;
            } while (!mav.IsLoaded && counter < 20000);
            counter = 0;
            var pedmod = new Model(PedHash.Pilot01SMY);
            do
            {
                pedmod.Request();
                Script.Yield();
                counter++;
            } while (!pedmod.IsLoaded && counter < 20000);
            heli = Function.Call<Vehicle>(Hash.CREATE_VEHICLE, mav.Hash, helipad.X, helipad.Y, helipad.Z, 0f, false, false);
            heli.Livery = 0;
            pilot = Function.Call<Ped>(Hash.CREATE_PED, 26, pedmod.Hash, helipad.X, helipad.Y, helipad.Z, 0f, false, false);
            Function.Call(Hash.SET_BLOCKING_OF_NON_TEMPORARY_EVENTS, pilot.Handle, 1);
            Function.Call(Hash.SET_PED_FLEE_ATTRIBUTES, pilot.Handle, 0, 0);
            Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, pilot.Handle, 17, 1);
            Function.Call(Hash.SET_PED_INTO_VEHICLE, pilot.Handle, heli.Handle, (int)VehicleSeat.Driver);
            /*
            void TASK_HELI_MISSION(Ped ped, Vehicle vehicle, Any p2, Any p3,
              float posX, float posY, float posZ, int mode, float speed1,
                float radius, float heading, int height1, int height2, float p13, int p14)

            modes:
            0, 1 - no takeoff?
            4 - Get height first, then fly mantaining heading
            6 - fly to point first, achieve heading later.
            20 - ignore height
            */
        }
Esempio n. 37
0
        /// <summary>
        /// Setup fighter for the AI player.
        /// </summary>
        public void Setup()
        {
            var vehModel = new Model(VehicleHash.Blimp);

            OutputArgument outVec = new OutputArgument(), outFlt = new OutputArgument();

            var pos = TeamManager.CenterMap;

            Function.Call(Hash.GET_RANDOM_VEHICLE_NODE, pos.X, pos.Y, pos.Z, 1200f, 1, 1, 1, outVec, outFlt);

            var spawnPos = Scripts.GetValidSpawnPos(outVec.GetResult<Vector3>() + new Vector3(0, 0, 400f));

            if (!vehModel.IsLoaded)
                vehModel.Request(1000);

            var vehicle = new ManageableVehicle(World.CreateVehicle(vehModel, spawnPos));
            vehicle.LodDistance = 2000;
            vehicle.Heading = outFlt.GetResult<float>();
            vehicle.Vehicle.EngineRunning = true;
            Function.Call(Hash.SET_VEHICLE_EXPLODES_ON_HIGH_EXPLOSION_DAMAGE, vehicle.Handle, true);

            vehicle.Vehicle.BodyHealth = 1000;
            vehicle.MaxHealth = 1000;
            vehicle.MaxSpeed = 0;

            var blip = vehicle.AddBlip();
            blip.Sprite = BlipSprite.Blimp;
            blip.Scale = 0.8f;
            blip.Alpha = 220;

            var cl = TeamManager.GetColorFromTeamIndex(Team.Index);

            Function.Call(Hash.SET_BLIP_SECONDARY_COLOUR, blip.Handle, cl.R, cl.G, cl.B);
            Function.Call((Hash)0xB81656BC81FE24D1, blip.Handle, 1);

            ManagedVehicle = vehicle;
        }
Esempio n. 38
0
File: Enemy.cs Progetto: Guad/NOOSE
 public Enemy(Vector3 position, float heading)
 {
     var tmpMod = new Model(_skins[Dice.Next(_skins.Length)]);
     int counter = 0;
     do
     {
         tmpMod.Request();
         Script.Yield();
         counter++;
     } while (!tmpMod.IsLoaded && counter < 10000);
     int c2 = 0;
     do
     {
         Character = Function.Call<Ped>(Hash.CREATE_PED, 26, tmpMod.Hash, position.X, position.Y, position.Z, heading, false, false);
         c2++;
     } while (Character == null && c2 < 3000);
     Character.Accuracy = Dice.Next(30, 100);
     Character.Weapons.Give(_guns[Dice.Next(_guns.Length)], 200, true, true);
     var relation = EnemyGroup;
     var relation2 = Game.Player.Character.RelationshipGroup;
     World.SetRelationshipBetweenGroups(Relationship.Hate, relation, relation2);
     World.SetRelationshipBetweenGroups(Relationship.Hate, relation2, relation);
     Character.RelationshipGroup = relation;
 }
Esempio n. 39
0
        public Teammate(Vector3 spawnpoint)
        {
            World.SetRelationshipBetweenGroups(Relationship.Respect, NOOSEGroup, Game.Player.Character.RelationshipGroup);

            World.SetRelationshipBetweenGroups(Relationship.Hate, NOOSEGroup, Enemy.EnemyGroup);
            World.SetRelationshipBetweenGroups(Relationship.Hate, Enemy.EnemyGroup, NOOSEGroup);

            var swatmodel = new Model(PedHash.Swat01SMY);
            int counter = 0;
            do
            {
                swatmodel.Request();
                Script.Yield();
                counter++;
            } while (!swatmodel.IsLoaded && counter < 10000);

            Character = Function.Call<Ped>(Hash.CREATE_PED, 26, swatmodel.Hash, spawnpoint.X, spawnpoint.Y, spawnpoint.Z, 0f, false, false);
            Character.Health = 200;
            Character.Armor = 200;
            Character.RelationshipGroup = NOOSEGroup;
            Character.AlwaysDiesOnLowHealth = false;
            Function.Call(Hash.REMOVE_PED_FROM_GROUP, Character.Handle);
            Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, Character.Handle, Function.Call<int>(Hash.GET_PED_GROUP_INDEX, Game.Player.Character.Handle));
        }
Esempio n. 40
0
        public void AddChildren(int count = 0)
        {
            var spawnPos = leader.Team.GroundSpawnPoint.Position;
            var pedModel = new Model(PedHash.Pilot02SMM);
            var vehModel = new Model(VehicleHash.Barracks3);

            if (!pedModel.IsLoaded)
                pedModel.Request(1000);

            if (!vehModel.IsLoaded)
                vehModel.Request(1000);

            for (int i = 0; i < count; i++)
            {
                var parent = children.Count > 0 ? children.Last() : leader ;

                var childAsset = new GroundAI();
                var pos = parent.ManagedVehicle.Position - parent.ManagedVehicle.ForwardVector * 6;
                var vehicle = new ManageableVehicle(World.CreateVehicle(vehModel, pos));

                vehicle.Vehicle.EngineRunning = true;
                vehicle.Vehicle.Heading = leader.Team.GroundSpawnPoint.Heading;
                vehicle.AddBlip();
                vehicle.CurrentBlip.Sprite = BlipSprite.BountyHit;

                Function.Call(Hash.SET_ENTITY_LOAD_COLLISION_FLAG, vehicle.Handle, true);

                var ped = new ManageablePed(new Ped(Function.Call<int>(Hash.CREATE_PED_INSIDE_VEHICLE, vehicle.Handle, 6, pedModel.Hash, -1, 0, 0)));
                ped.Ped.RelationshipGroup = leader.Team.RelationshipGroup;
                ped.Ped.BlockPermanentEvents = false;
                ped.Ped.SetIntoVehicle(vehicle.Vehicle, VehicleSeat.Driver);

                childAsset.Manage(ped, vehicle);
                children.Add(childAsset);
            }
        }
Esempio n. 41
0
        public void setDemagoModel(DemagoModel newModel)
        {
            if (newModel == DemagoModel.Joe)
            {
                if ((uint)Game.Player.Character.Model.Hash == (uint)PedHash.Acult01AMO)
                    return;

                Model joeModel = new Model(PedHash.Acult01AMO);
                joeModel.Request(500);
                if (joeModel.IsInCdImage && joeModel.IsValid)
                {
                    while (!joeModel.IsLoaded)
                        Script.Wait(0);

                    Function.Call(Hash.SET_PLAYER_MODEL, Game.Player.Handle, joeModel.Hash);
                    Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);

                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 0, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 1, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 2, 1, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 3, 1, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 4, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 5, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 6, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 7, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 8, 2, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 9, 1, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 10, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 11, 0, 0, 2);

                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 0, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 1, 0, 0, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 2, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 3, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 4, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 5, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 6, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 7, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 8, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 9, -1, -1, 2);
                }
            }

            if (newModel == DemagoModel.Fouras)
            {
                if ((uint)Game.Player.Character.Model.Hash == (uint)PedHash.PriestCutscene)
                    return;

                Model fourasModel = new Model(PedHash.PriestCutscene);
                fourasModel.Request(500);
                if (fourasModel.IsInCdImage && fourasModel.IsValid)
                {
                    while (!fourasModel.IsLoaded)
                        Script.Wait(0);

                    Function.Call(Hash.SET_PLAYER_MODEL, Game.Player.Handle, fourasModel.Hash);
                    Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);

                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 0, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 1, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 2, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 3, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 4, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 5, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 6, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 7, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 8, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 9, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 10, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 11, 0, 0, 2);

                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 0, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 1, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 2, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 3, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 4, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 5, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 6, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 7, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 8, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 9, -1, -1, 2);
                }
            }

            if (newModel == DemagoModel.Gastrow)
            {
                if ((uint)Game.Player.Character.Model.Hash == (uint)PedHash.Migrant01SFY)
                    return;

                Model gastrowModel = new Model(PedHash.Migrant01SFY);
                gastrowModel.Request(500);
                if (gastrowModel.IsInCdImage && gastrowModel.IsValid)
                {
                    while (!gastrowModel.IsLoaded)
                        Script.Wait(0);

                    Function.Call(Hash.SET_PLAYER_MODEL, Game.Player.Handle, gastrowModel.Hash);
                    Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);

                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 0, 1, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 1, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 2, 1, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 3, 1, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 4, 1, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 5, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 6, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 7, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 8, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 9, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 10, 0, 0, 2);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 11, 0, 0, 2);

                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 0, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 1, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 2, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 3, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 4, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 5, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 6, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 7, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 8, -1, -1, 2);
                    Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, 9, -1, -1, 2);
                }
            }
        }
Esempio n. 42
0
        /// <summary>
        /// Reset old player model
        /// </summary>
        public void resetPlayerModel()
        {
            bool playerWasDead = false;
            bool playerWasArrested = false;
            Ped player = Game.Player.Character;
            if ((PedHash)player.Model.Hash != DemagoScript.savedPlayerModelHash)
            {
                Vehicle currentVehicle = null;
                if (player.IsInVehicle())
                {
                    currentVehicle = player.CurrentVehicle;
                }

                if (player.IsDead || Function.Call<bool>(Hash.IS_PLAYER_BEING_ARRESTED, Game.Player, false))
                {
                    #region Create remplacement ped
                    Ped replacementPed = Function.Call<Ped>(Hash.CLONE_PED, Game.Player.Character, Function.Call<int>(Hash.GET_ENTITY_HEADING, Function.Call<int>(Hash.PLAYER_PED_ID)), false, true);

                    if (player.IsDead)
                    {
                        playerWasDead = true;
                        replacementPed.Kill();
                    }
                    else
                    {
                        playerWasArrested = true;
                        replacementPed.Task.HandsUp(10000);
                    }

                    replacementPed.MarkAsNoLongerNeeded();
                    #endregion
                }

                #region Change player model with saved PedHash
                var characterModel = new Model(DemagoScript.savedPlayerModelHash);
                characterModel.Request(500);

                if (characterModel.IsInCdImage && characterModel.IsValid)
                {
                    while (!characterModel.IsLoaded) Script.Wait(100);

                    Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, characterModel.Hash);
                    Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);
                }

                characterModel.MarkAsNoLongerNeeded();
                #endregion

                player = Game.Player.Character;
                if (currentVehicle != null)
                {
                    player.SetIntoVehicle(currentVehicle, VehicleSeat.Driver);
                }

                if ((playerWasDead || playerWasArrested) && DemagoScript.isThereACurrentMission())
                {
                    #region Hide real player and wait for game recovery
                    player.IsVisible = false;
                    player.IsInvincible = true;
                    player.Task.StandStill(-1);

                    //Tant qu'on charge le jeu, on fait attendre le script GTA Démago
                    while (!Function.Call<bool>(Hash.IS_PLAYER_PLAYING, Game.Player))
                    {
                        Script.Wait(100);
                    }

                    player.IsVisible = true;
                    player.IsInvincible = false;
                    #endregion

                    while (!Function.Call<bool>(Hash.IS_PLAYER_CONTROL_ON, Game.Player))
                    {
                        Script.Wait(100);
                    }

                    #region Show death or arrested popups
                    var title = (playerWasDead) ? "Vous êtes mort" : "Vous vous êtes fait arrêter";
                    var subtitle = "Voulez-vous revenir au dernier checkpoint ?";

                    ConfirmationPopup checkpointPopup = new ConfirmationPopup(title, subtitle);
                    checkpointPopup.OnPopupAccept += () =>
                    {

                        DemagoScript.loadLastCheckpointOnCurrentMission();
                    };
                    checkpointPopup.OnPopupRefuse += () =>
                    {
                        DemagoScript.stopCurrentMission(true);
                    };
                    checkpointPopup.show();
                    #endregion
                }
            }
        }
Esempio n. 43
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(!CreatedNpcBlips)
            {
                foreach (var npc in NpcDatas)
                {
                    var blip = World.CreateBlip(npc.Position);
                    blip.Sprite = npc.BlipSprite;
                    WorldData.Blips.Add(new BlipObject("Blip_" + npc.Name, blip));
                }
                CreatedNpcBlips = true;
            }

            if(!PlayerData.Tutorial.BoughtAmmoFromShop && PlayerData.Tutorial.PressJToOpenMenu)
            {
                var tut = RPG.GetPopup<TutorialBox>();
                var ammo = PlayerData.Inventory.FirstOrDefault(i => i.Name == "Ammo Pack I");
                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.");
                        }
                    });
                }
            }

            CheckNpcs();

            foreach(var l in RPG.WorldData.Loot)
            {
                if(l.Prop != null && l.Prop.Exists() && l.Item != null)
                {
                    if(RPG.UIHandler.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 = World.GetAllVehicles();
            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 = World.GetAllPeds();
            //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
                    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();
        }
Esempio n. 44
0
        public void StartEntry(int entryPoint, Ped[] team)
        {
            switch (entryPoint)
            {
                case 0: // Rappel
                    Vector3[] helipads = new[]
                    {
                        new Vector3(311.313f, -1466f, 46.9f),
                        new Vector3(299.75f, -1453f, 46.9f),
                    };
                    for (int i = 0; i < Convert.ToInt32(team.Length/2); i++)
                    {
                        var rappel = new RappelEntry(helipads[i], new Vector3(-92.5652f, -2362.343f, 31.9f));
                        var team2 = team.Reverse().ToList();
                        for (int d = 0 + (2*i); d < 2 + (2*i); d++)
                        {
                            Ped t = team2[d];
                            rappel.AddPassenger(t);
                        }
                        rappelUpdates.Add(rappel);
                    }
                    break;
                case 1: //boat
                    BadGuys[BadGuys.Count-1].Character.Delete();
                    BadGuys.RemoveAt(BadGuys.Count-1);

                    var boatModel = new Model(VehicleHash.Dinghy2);
                    int counter = 0;
                    do
                    {
                        boatModel.Request();
                        Script.Yield();
                        counter++;
                    } while (!boatModel.IsLoaded && counter < 2000);

                    var boat = World.CreateVehicle(boatModel, new Vector3(-253.971f, -2367.186f, -0.89f), 185.44f);
                    boat.MarkAsNoLongerNeeded();
                    CleanupBag.Add(boat);

                    foreach (Ped t in team)
                    {
                        t.Position = new Vector3(-249.4635f, -2366.84f, 9.319f);
                        t.Heading = -180f;
                    }
                    EntryComplete = true;
                    break;

            }
        }
Esempio n. 45
0
        private void CarSelection()
        {
            //var p = new Point(UI.WIDTH / 2 - 150, UI.HEIGHT - 225);
            //new UIRectangle(new Point(p.X, p.Y + 25), new Size(300, 20), Color.FromArgb(180, 8, 8, 8)).Draw();
            //new UIText("Name: " + PlayerName, new Point(p.X + 150, p.Y + 25), 0.25f, Color.White, 0, true).Draw();
            //new UIText((CarModel != null && (CarModel.Model.IsCar || CarModel.Model.IsBike || CarModel.Model.IsBicycle || CarModel.Model.IsHelicopter || CarModel.Model.IsPlane || CarModel.Model.IsQuadbike)
            //    ? "Drivable" : "Not Driveable"), new Point(p.X + 150, p.Y - 5), 0.25f, Color.White, 0, true).Draw();
            //var name = "License Plate:" + CarPlate;
            //
            //new UIRectangle(new Point(p.X, p.Y + 50), new Size(300, 20), Color.FromArgb(180, 8, 8, 8)).Draw();
            //new UIText(name, new Point(p.X + 150, p.Y + 50), 0.25f, Color.White, 0, true).Draw();

            if (!IsOpen(CarSelectMenu))
            {
                if (CharacterModel != null) CharacterModel.Delete();
                View.AddMenu(CarSelectMenu);
            }

            if (CarModel == null)
            {
                var m = new Model(AvailableCars[CurrentCarModel]);
                m.Request(1000);
                CarModel = World.CreateVehicle(m, _carPosition, _carHeading);
                RPG.WorldData.AddVehicle(new VehicleObject("charCreation", CarModel));

                CarModel.PrimaryColor = AvailableColors[CurrentCarColor];
                CarModel.SecondaryColor = AvailableSecondaryColors[CurrentCarSecondaryColor];
                CarModel.NumberPlate = "";
                CarModel.NumberPlate = CarPlate;
                CarModel.RoofState = VehicleRoofState.Closed;
                Camera.Position = _camPosition + new Vector3(CarModel.Model.GetDimensions().Y, CarModel.Model.GetDimensions().Y/3, 0);
                if (CarModel != null && !(CarModel.Model.IsCar || CarModel.Model.IsBike || CarModel.Model.IsBicycle || CarModel.Model.IsHelicopter || CarModel.Model.IsPlane || CarModel.Model.IsQuadbike))
                {
                    CarModel.Delete();
                    CarModel = null;
                    NextModel();
                }

                if (CarModel != null)
                {
                    Camera.PointAt(CarModel);
                }
            }
            else
            {
                CarModel.FreezePosition = true;
                //CarModel.Rotation = new Vector3(CarModel.Rotation.X, CarModel.Rotation.Y, CarModel.Rotation.Z + 0.05f);
            }
        }
Esempio n. 46
0
        private void ReadSetPlayerModelPacket(NetIncomingMessage netIncomingMessage)
        {
            int playerId = netIncomingMessage.ReadInt32();
            uint modelId = (uint)netIncomingMessage.ReadInt32();

            foreach (NetworkPlayer serverNetworkPlayer in Players) {
                if (serverNetworkPlayer.PlayerID == playerId) {
                    serverNetworkPlayer.Model = modelId;

                    var characterModel = new Model((PedHash)serverNetworkPlayer.Model);
                    characterModel.Request(500);

                    if (serverNetworkPlayer.LocalPlayer) {
                        // Check the model is valid
                        if (characterModel.IsInCdImage && characterModel.IsValid) {
                            // If the model isn't loaded, wait until it is
                            while (!characterModel.IsLoaded) Script.Wait(100);

                            // Set the player's model
                            Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, characterModel.Hash);
                            Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);
                        }

                        Main.ChatBox.Add("DEBUG: Model has been set to: " + modelId);
                    }

                    // We don't want to do ped things on our own player, because we don't have our own physical ped
                    if (Main.CloneSync || GetLocalPlayer().PlayerID != playerId) {
                        SetPlayerPed(serverNetworkPlayer, serverNetworkPlayer.Model);
                        //Function.Call(Hash.SET_PLAYER_MODEL, serverNetworkPlayer.Ped, serverNetworkPlayer.Model);
                    }

                    // Delete the model from memory after we've assigned it
                    characterModel.MarkAsNoLongerNeeded();
                }
            }
        }
Esempio n. 47
0
        // Funtion to set Player Model
        // Menu Functions End ---------- Don't Mess with Them
        private void SetPlayerModel()
        {
            Game.FadeScreenOut(250);
            Wait(250);
            if (active == true)
            {
                playermodel = Game.Player.Character.Model;
                var characterModel = new Model(PedHash.Zombie01);
                characterModel.Request(500);

                // Check the model is valid
                if (characterModel.IsInCdImage && characterModel.IsValid)
                {

                    while (!characterModel.IsLoaded) Script.Wait(100);

                    Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, characterModel.Hash);
                    Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);
                }

                characterModel.MarkAsNoLongerNeeded();
                player = Game.Player.Character;
            }
            else
            {
                playermodel.Request(500);

                // Check the model is valid
                if (playermodel.IsInCdImage && playermodel.IsValid)
                {

                    while (!playermodel.IsLoaded) Script.Wait(100);

                    Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, playermodel.Hash);
                    Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);
                }
                playermodel.MarkAsNoLongerNeeded();
                player = Game.Player.Character;
            }
            Game.FadeScreenIn(250);
        }
Esempio n. 48
0
        private void CheckNpcs()
        {
            foreach(var npc in NpcDatas)
            {
                var dist = npc.Position.DistanceTo(Game.Player.Character.Position);
                var npcStatus = npc.GetNpcStatus();
                var npcBlip = WorldData.Blips.FirstOrDefault(b => b.Name == "Blip_" + npc.Name);
                if(npcBlip != null)
                {
                    var blipPos = npcBlip.Blip.Position;

                    if(string.IsNullOrEmpty(npcStatus))
                    {
                        if (npcBlip.Blip.Sprite != npc.BlipSprite)
                        {
                            npcBlip.Blip.Remove();
                            npcBlip.Blip = World.CreateBlip(blipPos);
                            npcBlip.Blip.Sprite = npc.BlipSprite;
                        }
                    }
                    else
                    {
                        var importantMarker = npcStatus[0];
                        switch(importantMarker)
                        {
                            case '!':
                                if (npcBlip.Blip.Sprite != BlipSprite.Information)
                                {
                                    npcBlip.Blip.Remove();
                                    npcBlip.Blip = World.CreateBlip(blipPos);
                                    npcBlip.Blip.Sprite = BlipSprite.Information;
                                }
                                break;
                            case '?':
                                if (npcBlip.Blip.Sprite != BlipSprite.GTAOMission)
                                {
                                    npcBlip.Blip.Remove();
                                    npcBlip.Blip = World.CreateBlip(blipPos);
                                    npcBlip.Blip.Sprite = BlipSprite.GTAOMission;
                                }
                                break;
                            case '*':
                                if (npcBlip.Blip.Sprite != BlipSprite.ChatBubble)
                                {
                                    npcBlip.Blip.Remove();
                                    npcBlip.Blip = World.CreateBlip(blipPos);
                                    npcBlip.Blip.Sprite = BlipSprite.ChatBubble;
                                }
                                break;
                            case '$':
                                if (npcBlip.Blip.Sprite != BlipSprite.Store)
                                {
                                    npcBlip.Blip.Remove();
                                    npcBlip.Blip = World.CreateBlip(blipPos);
                                    npcBlip.Blip.Sprite = BlipSprite.Store;
                                }
                                break;
                        }
                    }
                }

                if (RPGSettings.ShowUI && RPG.UIHandler.CurrentDialog == null)
                {
                    if (npc.IsQuestNpc && dist < 20)
                    {
                        var pos = npc.Ped != null ? npc.Ped.Position : npc.Position;
                        pos.Z += 1.0f;
                        OutputArgument xArg = new OutputArgument();
                        OutputArgument yArg = new OutputArgument();
                        Function.Call(Hash._WORLD3D_TO_SCREEN2D, pos.X, pos.Y, pos.Z, xArg, yArg);
                        var x = xArg.GetResult<float>();
                        var y = yArg.GetResult<float>();

                        new UIRectangle(new Point((int) (UI.WIDTH*x) - 50, (int) (UI.HEIGHT*y) + 12), new Size(100, 2), Color.DodgerBlue).Draw();
                        new UIText(npc.Name, new Point((int) (UI.WIDTH*x), (int) (UI.HEIGHT*y)), 0.21f, Color.White, 0, true).Draw();

                        if(!string.IsNullOrEmpty(npcStatus))
                            new UIText(npcStatus, new Point((int)(UI.WIDTH * x), (int)(UI.HEIGHT * y) - 35), 0.8f, Color.Gold, 0, true).Draw();
                    }
                }
                if(npc.IsQuestNpc && !npc.Spawned)
                {

                    //RPGLog.Log("Found unspawned NPC");
                    if (dist < 100)
                    {
                        RPGLog.Log("Spawning NPC");
                        var model = new Model(npc.ModelName);
                        model.Request(1000);
                        var ped = World.CreatePed(model, npc.Position, npc.Heading);

                        try
                        {
                            ped.RelationshipGroup = Game.Player.Character.RelationshipGroup;
                            ped.IsInvincible = true;
                            EventHandler.Do(o =>
                                                {
                                                    EventHandler.Wait(1000);
                                                    ped.FreezePosition = true;
                                                });
                            Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, ped.Handle);
                            Function.Call(Hash.SET_PED_CAN_BE_TARGETTED, ped.Handle, false);
                            Function.Call(Hash.SET_PED_CAN_BE_TARGETTED_BY_PLAYER, ped.Handle, false);
                        }
                        catch
                        {
                            RPGLog.Log("Error setting npc and player friendliness.");
                        }
                        npc.SetPed(ped);
                        npc.Spawned = true;
                    }
                }
            }
        }
Esempio n. 49
0
        void Onkeyup(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.F12) && (Game.Player.WantedLevel > 1))
            {
            hours = 10 + (Game.Player.WantedLevel * 10);
            Game.Player.WantedLevel = 0;
            intial1();
            }
            if ((e.KeyCode == Keys.E) && arrested)
            {
            if ((Game.Player.Character.Position.DistanceTo(new Vector3(1691.709f, 2565.036f, 45.56487f)) < 2f) && (Game.Player.Money > 0x4c4b40))
            {
                bail.Remove();
                roit.Remove();
                Game.Player.Character.Position = new Vector3(1849.555f, 2586.085f, 45.67202f);
                Game.Player.Character.Heading = 258.4564f;
                Player player = Game.Player;
                player.Money -= 0x4c4b40;
                Function.Call(Hash.SET_MAX_WANTED_LEVEL, 5 );
                Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character);
                arrested = false;
                _headsup = null;
                _headsupRectangle = null;
            }
            if ((Game.Player.Character.Position.DistanceTo(new Vector3(1625.474f, 2491.485f, 45.62026f)) < 4f) && !escape)
            {
                stop_scripts();
                bail.Remove();
                roit.Remove();
                Player player2 = Game.Player;
                player2.Money -= 0x4c4b40;
                stop_scripts();
                arrested = false;
                _headsup = null;
                _headsupRectangle = null;

                Model mod = new Model(VehicleHash.Valkyrie);
                mod.Request();
                while (!mod.IsLoaded)
                {
                    stop_scripts();
                    Script.Wait(0);
                }
                escape_veh3 = World.CreateVehicle(mod, new Vector3(-1179.25f, -2845.386f, 13.5665f));
                escape_veh3.Heading = 325.6199f;
                escape_veh3.IsPersistent = true;
                mod.MarkAsNoLongerNeeded();
                //============================================================================================================
                mod = new Model(VehicleHash.Comet2);
                mod.Request();
                while (!mod.IsLoaded)
                {
                    stop_scripts();
                    Script.Wait(0);
                }
                escape_veh1 = World.CreateVehicle(mod, new Vector3(-1729.416f, -1109.523f, 12.7468f));
                escape_veh1.Heading = 321.1888f;
                escape_veh1.IsPersistent = true;
                mod.MarkAsNoLongerNeeded();
                //===========================================================================================================
                mod = new Model(VehicleHash.Insurgent2);
                mod.Request();
                while (!mod.IsLoaded)
                {
                    stop_scripts();
                    Script.Wait(0);
                }
                escape_veh2 = World.CreateVehicle(mod, new Vector3(1373.179f, -2077.577f, 51.6181f));
                escape_veh2.Heading = 332.3142f;
                escape_veh2.IsPersistent = true;
                mod.MarkAsNoLongerNeeded();

                int hash = Function.Call<int>(Hash.GET_ENTITY_MODEL, new InputArgument[] { Game.Player.Character });
                if (hash == Function.Call<int>(Hash.GET_HASH_KEY, new InputArgument[] { "player_zero" }))    //m
                {
                    mod = new Model(PedHash.Franklin);
                    mod.Request();
                    while (!mod.IsLoaded)
                    {
                        stop_scripts();
                        Script.Wait(0);
                    }
                    escape_ped1 = World.CreatePed(mod, new Vector3(-1726.644f, -1112.538f, 13.2474f));
                    escape_ped1.Heading = 42.1536f;
                    escape_ped1.IsPersistent = true;
                    mod.MarkAsNoLongerNeeded();

                    mod = new Model(PedHash.Trevor);
                    mod.Request();
                    while (!mod.IsLoaded)
                    {
                        stop_scripts();
                        Script.Wait(0);
                    }
                    escape_ped2 = World.CreatePed(mod, new Vector3(1376.8f, -2076.873f, 51.9985f));
                    escape_ped2.Heading = 47.19263f;
                    escape_ped2.IsPersistent = true;
                    mod.MarkAsNoLongerNeeded();

                }
                else if (hash == Function.Call<int>(Hash.GET_HASH_KEY, new InputArgument[] { "player_one" })) //f
                {
                    mod = new Model(PedHash.Michael);
                    mod.Request();
                    while (!mod.IsLoaded)
                    {
                        stop_scripts();
                        Script.Wait(0);
                    }
                    escape_ped1 = World.CreatePed(mod, new Vector3(-1726.644f, -1112.538f, 13.2474f));
                    escape_ped1.Heading = 42.1536f;
                    escape_ped1.IsPersistent = true;
                    mod.MarkAsNoLongerNeeded();

                    mod = new Model(PedHash.Trevor);
                    mod.Request();
                    while (!mod.IsLoaded)
                    {
                        stop_scripts();
                        Script.Wait(0);
                    }
                    escape_ped2 = World.CreatePed(mod, new Vector3(1376.8f, -2076.873f, 51.9985f));
                    escape_ped2.Heading = 47.19263f;
                    escape_ped2.IsPersistent = true;
                    mod.MarkAsNoLongerNeeded();
                }
                else if (hash == Function.Call<int>(Hash.GET_HASH_KEY, new InputArgument[] { "player_two" }))//tr
                {
                    mod = new Model(PedHash.Michael);
                    mod.Request();
                    while (!mod.IsLoaded)
                    {
                        stop_scripts();
                        Script.Wait(0);
                    }
                    escape_ped1 = World.CreatePed(mod, new Vector3(-1726.644f, -1112.538f, 13.2474f));
                    escape_ped1.Heading = 42.1536f;
                    escape_ped1.IsPersistent = true;
                    mod.MarkAsNoLongerNeeded();

                    mod = new Model(PedHash.Franklin);
                    mod.Request();
                    while (!mod.IsLoaded)
                    {
                        stop_scripts();
                        Script.Wait(0);
                    }
                    escape_ped2 = World.CreatePed(mod, new Vector3(1376.8f, -2076.873f, 51.9985f));
                    escape_ped2.Heading = 47.19263f;
                    escape_ped2.IsPersistent = true;
                    mod.MarkAsNoLongerNeeded();
                }
                original_ped = Game.Player.Character;

                Game.FadeScreenOut(3000);
                while (!Function.Call<bool>(Hash.IS_SCREEN_FADED_OUT))
                    Script.Wait(0);
                Function.Call(Hash.CHANGE_PLAYER_PED, Game.Player, escape_ped1, 1, 0);
                Game.FadeScreenIn(3000);
                while (!Function.Call<bool>(Hash.IS_SCREEN_FADED_IN))
                    Script.Wait(0);
                current_ped = 1;
                vehb = escape_veh1.AddBlip();
                vehb.Color = BlipColor.Blue;
                UI.ShowSubtitle("Get in the ~b~ Vehicle",3000);
                steps = 0;

                player_status = status.In_escape;
                Function.Call(Hash.SET_MAX_WANTED_LEVEL,  5);

                escape = true;
            }
            }
            if (e.KeyCode == Keys.E && steps == 5)
            {
            if (current_ped == 1)
            {
                Function.Call(Hash.CHANGE_PLAYER_PED, Game.Player, escape_ped2, 1, 0);
                //drive task

                current_ped = 2;
            }
            else
            {
                Function.Call(Hash.CHANGE_PLAYER_PED, Game.Player, escape_ped1, 1, 0);
                //shot task
                escape_ped2.Task.FightAgainstHatedTargets(150f);
                escape_ped2.AlwaysKeepTask = true;
                current_ped = 1;
            }
            }
            if (((e.KeyCode == Keys.Y) && arrested) && (Game.Player.Character.Position.DistanceTo(escape_Ped.Position) < 4f))
            {
            time = Game.GameTime;
            int i;
            for (i = 0; i < prisoner.Count; i++)
            {
                GiveWeapons_prisoner(prisoner[i]);
                prisoner[i].CanSwitchWeapons = true;

            }
            for (i = 0; i < garde.Count; i++)
            {
                GiveWeapons_Garde(garde[i]);
                garde[i].CanSwitchWeapons = true;
                //Function.Call(Hash.SET_BLOCKING_OF_NON_TEMPORARY_EVENTS, garde[i], true);

            }
            GiveWeapons_prisoner(Game.Player.Character);
            Player player3 = Game.Player;
            player3.Money -= 0x4c4b40;
            Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, new InputArgument[] { 5, 0x7ea26372, -183807561 });
            Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, new InputArgument[] { 5, -183807561, 0x7ea26372 });
            }

            if (((e.KeyCode == Keys.E) && (player_status == status.In_road)) && !sciped)
            {
            try
            {
                Game.FadeScreenOut(3000);
                while (!Function.Call<bool>(Hash.IS_SCREEN_FADED_OUT))
                {
                    Script.Wait(0);
                }

                policecar.Position = new Vector3(2124.503f, 2760.919f, 49.1893f);
                policecar.Heading = 130.5902f;

                Game.FadeScreenIn(3000);
                sciped = true;
            }
            catch (Exception ex)
            {
                SimpleLog.Error(ex);
                throw;
            }

            }
        }
Esempio n. 50
0
        public void intial1()
        {
            Game.Player.WantedLevel = 0;
            Game.Player.Character.Weapons.RemoveAll();
            Function.Call(Hash.DISABLE_ALL_CONTROL_ACTIONS, new InputArgument[] { 1 });

            Function.Call(Hash.SET_ENABLE_HANDCUFFS, new InputArgument[] { Game.Player.Character, 1 });
            Function.Call(Hash.SET_ENABLE_BOUND_ANKLES, new InputArgument[] { Game.Player.Character, 1 });
            Game.Player.Character.Task.ClearAllImmediately();
            Game.Player.Character.Task.HandsUp(0xbb8);
            Script.Wait(0xbb8);
            Function.Call(Hash.CLEAR_RELATIONSHIP_BETWEEN_GROUPS, new InputArgument[] { 5, 0x7ea26372, -183807561 });
            Function.Call(Hash.CLEAR_RELATIONSHIP_BETWEEN_GROUPS, new InputArgument[] { 5, -183807561, 0x7ea26372 });
            Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, new InputArgument[] { 0xff, 0x7ea26372, -183807561 });
            Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, new InputArgument[] { 0xff, -183807561, 0x7ea26372 });
            escape_Ped = World.CreatePed(0x7b9b4bc0, new Vector3(1625.474f, 2491.485f, 45.62026f));
            escape_Ped.Task.StandStill(-1);
            escape_Ped.AlwaysKeepTask = true;
            escape_Ped.Heading = 320.5151f;
            Function.Call(Hash.SET_ENTITY_AS_MISSION_ENTITY, new InputArgument[] { escape_Ped, 1, 1 });
            Function.Call(Hash.SET_MAX_WANTED_LEVEL, new InputArgument[] { 0 });
            Model model = new Model(PedHash.Prisguard01SMM);
            model.Request(0x3e8);
            while (!model.IsLoaded)
            {
                Script.Wait(0);
            }
            police = World.CreatePed(model, Game.Player.Character.Position.Around(10f));
            Model model2 = new Model(VehicleHash.Police);
            model2.Request(0x3e8);
            while (!model2.IsLoaded)
            {
                Script.Wait(0);
            }
            policecar = World.CreateVehicle(model2, Game.Player.Character.Position.Around(10f));
            Game.Player.Character.Task.ClearAllImmediately();
            Game.Player.Character.Task.EnterVehicle(policecar, VehicleSeat.LeftRear);
            while (!Game.Player.Character.IsInVehicle(policecar))
            {
                Script.Wait(0);
            }
            police.Task.ClearAllImmediately();
            police.RelationshipGroup = Game.Player.Character.RelationshipGroup;
            police.Task.ClearAllImmediately();
            police.Task.WarpIntoVehicle(policecar, VehicleSeat.Driver);
            while (!police.IsInVehicle(policecar))
            {
                Script.Wait(0);
            }

            player_status = status.In_road;
            UI.Notify("press ~g~[E]~w~ to skip");
            policecar.SirenActive = true;
            string s = "402c1827";
            int num = int.Parse(s, NumberStyles.HexNumber);
            Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, new InputArgument[] { police, policecar, new Vector3(1764.323f, 2604.595f, 45.56498f).X, new Vector3(1764.323f, 2604.595f, 45.56498f).Y, new Vector3(1764.323f, 2604.595f, 45.56498f).Z, 20f, num, 1f });
            testt = true;
        }
Esempio n. 51
0
 public static Vehicle SpawnVehicleProper(Model m, Vector3 pos)
 {
     m.Request();
     Function.Call(Hash.REQUEST_MODEL, m.Hash);
     int i = 10000;
     while (!Function.Call<bool>(Hash.HAS_MODEL_LOADED, m.Hash) && i > 0) {
         i--;
         Script.Wait(0);
     }
     return new Vehicle(Function.Call<int>(Hash.CREATE_VEHICLE, m.Hash, pos.X, pos.Y, pos.Z, 0, 0));
 }
Esempio n. 52
0
        public void ReadInitializationPacket(NetIncomingMessage netIncomingMessage)
        {
            int playerId = netIncomingMessage.ReadInt32();
            float posX = netIncomingMessage.ReadFloat();
            float posY = netIncomingMessage.ReadFloat();
            float posZ = netIncomingMessage.ReadFloat();
            bool safeForNet = netIncomingMessage.ReadBoolean();

            // Sets actual playerid
            CreateNetworkPlayer(playerId, posX, posY, posZ, true);

            // Changes the physical location
            Vector3 position = new Vector3(posX, posY, posZ);
            Game.Player.Character.Position = position;

            // Removes all weapons from player
            Game.Player.Character.Weapons.RemoveAll();

            // Set default server synchronized player model
            var characterModel = new Model(PedHash.Brad);
            characterModel.Request(500);

            // Check the model is valid
            if (characterModel.IsInCdImage && characterModel.IsValid) {
                // If the model isn't loaded, wait until it is
                while (!characterModel.IsLoaded) Script.Wait(100);

                // Set the player's model
                Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, characterModel.Hash);
                Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);

                GetLocalPlayer().Model = (uint)PedHash.Brad;
            }

            // Delete the model from memory after we've assigned it
            characterModel.MarkAsNoLongerNeeded();

            Main.ChatBox.Add("(internal) Allocated PlayerID: " + GetLocalPlayer().PlayerID);
            //Main.ChatBox.Add("(internal) Packet data: " + receivedPacket + ", " + playerId + ", " + posX + ", " + posY + ", " + posZ + ", " + safeForNet);

            WorldRelationship = World.AddRelationshipGroup("AMP_PED");
            World.SetRelationshipBetweenGroups(Relationship.Companion, WorldRelationship, Game.Player.Character.RelationshipGroup); // Make the opposing party ally us (no fleeing)
            World.SetRelationshipBetweenGroups(Relationship.Neutral, Game.Player.Character.RelationshipGroup, WorldRelationship);

            // Sets safe for net flag
            SafeForNet = safeForNet;
        }
Esempio n. 53
0
 public void ChangePlayerModel(PedHash hash)
 {
     var model = new Model(hash);
     // only in recent script hook
     /*
     if (!Game.Player.ChangeModel(model))
     {
         UI.Notify("could not request model");
     }
     */
     if (!model.IsInCdImage || !model.IsPed || !model.Request(1000))
     {
         UI.Notify("could not request model");
     }
     else
     {
         Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, model.Hash);
         Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);
         if (hash == PedHash.FreemodeMale01 || hash == PedHash.FreemodeFemale01)
         {
             // must call SET_PED_HEAD_BLEND_DATA otherwise head overlays don't work
             var slot_key = new SlotKey(SlotType.Parent, 0);
             var slot_value = new SlotValue(0, 0, 4, 4);
             var ped = Game.Player.Character;
             SetSlotValue(ped, slot_key, slot_value);
         }
         data.Clear();
     }
     model.MarkAsNoLongerNeeded();
 }
Esempio n. 54
0
        private void CheckNpcs()
        {
            foreach(var npc in NpcDatas)
            {
                var dist = npc.Position.DistanceTo(Game.Player.Character.Position);
                if (dist < 20)
                {
                    var pos = npc.Ped != null ? npc.Ped.Position : npc.Position;
                    pos.Z += 1.0f;
                    OutputArgument xArg = new OutputArgument();
                    OutputArgument yArg = new OutputArgument();
                    Function.Call(Hash._WORLD3D_TO_SCREEN2D, pos.X, pos.Y, pos.Z, xArg, yArg);
                    var x = xArg.GetResult<float>();
                    var y = yArg.GetResult<float>();

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

                if(npc.IsQuestNpc && !npc.Spawned)
                {
                    //RPGLog.Log("Found unspawned NPC");
                    if (dist < 100)
                    {
                        //RPGLog.Log("Spawning NPC");
                        var model = new Model(npc.ModelName);
                        model.Request(1000);
                        var ped = World.CreatePed(model, npc.Position, npc.Heading);

                        try
                        {
                            ped.RelationshipGroup = Game.Player.Character.RelationshipGroup;
                            ped.IsInvincible = true;
                            Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, ped.Handle);
                            Function.Call(Hash.SET_PED_CAN_BE_TARGETTED, ped.Handle, false);
                            Function.Call(Hash.SET_PED_CAN_BE_TARGETTED_BY_PLAYER, ped.Handle, false);
                        }
                        catch
                        {
                            RPGLog.Log("Error setting npc and player friendliness.");
                        }
                        npc.SetPed(ped);
                        npc.Spawned = true;
                    }
                }

            }
        }
Esempio n. 55
0
        public void SetupCondition(QuestCondition c, bool firstSetup)
        {
            if (c.Type == ConditionType.Kill && c.Parameters.ContainsKey("ModelHash")
                    || c.Type == ConditionType.Loot && c.Parameters.ContainsKey("ModelHash"))
            {
                int[] hashes;
                var models = c.Parameters["ModelHash"] as uint[];
                var modelsA = c.Parameters["ModelHash"] as JArray;

                if (models != null)
                {
                    hashes = models.Select(m => (int)m).ToArray();
                }
                else
                {
                    hashes = modelsA.Select(jv => (uint)jv).Select(t => (int)t).ToArray();
                }

                if (SpawnTargets)
                {
                    c.Position = c.Position == Vector3.Zero ? RPGMethods.GetSpawnPoint(350) : c.Position;
                    BlipObjects.Add(RPGBlips.QuestArea(Name, c.Position));

                    EventHandler.Do(q =>
                    {
                      var pos = c.Position;
                      var amountToSpawn = AmountToSpawn;
                      var playerGroup = Game.Player.Character.RelationshipGroup;
                      var enemies = World.AddRelationshipGroup("RPG_Enemies");
                      World.SetRelationshipBetweenGroups(Relationship.Neutral, playerGroup, enemies);
                      for (int i = 0; i < amountToSpawn; i++)
                      {
                          var hash = hashes[Random.Range(0, hashes.Length)];
                          var m = new Model(hash);
                          m.Request(1000);
                          var ped = World.CreatePed(m, pos + Vector3.RandomXY() * 2, Game.Player.Character.Heading + 180);
                          ped.RelationshipGroup = enemies;
                          var b = ped.AddBlip();
                          EventHandler.Wait(100);
                          b.IsFriendly = false;
                          b.Scale = 0.6f;
                          ped.Task.WanderAround();
                          //todo: apply some weapon damage scaling here lol
                          ped.Weapons.Give(WeaponHash.Pistol, 1000, false, true);
                          ped.CanSwitchWeapons = true;
                          RPG.WorldData.AddPed(new NpcObject("Quest_" + Name, ped));
                          RPG.WorldData.AddBlip(new BlipObject("Quest_" + Name, b));
                          HasSpawnedTargets = true;
                      }
                    });

                }
            }

            if (!c.Parameters.ContainsKey("Current"))
            {
                c.Parameters.Add("Current", 0);
            }

            if(firstSetup)
            {
                switch (c.Type)
                {
                    case ConditionType.Kill:
                    case ConditionType.Loot:
                    case ConditionType.DestroyVehicle:
                    case ConditionType.Acquire:
                        c.Parameters["Current"] = 0;
                        break;
                    case ConditionType.Interact:
                    case ConditionType.Escort:
                    case ConditionType.Race:
                    case ConditionType.EvadeCops:
                        c.Parameters["Current"] = false;
                        break;
                    case ConditionType.Custom:
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
        }
Esempio n. 56
0
        private void DropQuestItem(Entity entity, string propModel, string itemName, int dropRateOutOf100)
        {
            var rng = Random.Range(0, 100 + 1);
            if (rng > dropRateOutOf100) return;

            var item = ItemRepository.Get(itemName);

            var m = new Model(GM.GetHashKey(propModel));
            m.Request(1000);

            var p = World.CreateProp(m, entity.Position + new Vector3(0, 0, 2.2F) + Vector3.RandomXY(), entity.Rotation, true, false);
            p.ApplyForce(new Vector3(0, 0, 0.05f));
            RPG.WorldData.AddLoot(new LootItem(item, p));
        }
Esempio n. 57
0
        public static void SetModel(PedHash pedhash)
        {
            var characterModel = new Model(pedhash);
            characterModel.Request(500);

            // Check the model is valid
            if (characterModel.IsInCdImage && characterModel.IsValid)
            {
                // If the model isn't loaded, wait until it is
                while (!characterModel.IsLoaded) Script.Wait(100);

                // Set the player's model
                Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, characterModel.Hash);
                Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character.Handle);
            }

            // Delete the model from memory after we've assigned it
            characterModel.MarkAsNoLongerNeeded();
        }
Esempio n. 58
0
        public void StartEntry(int entryPoint, Ped[] team)
        {
            switch (entryPoint)
            {
                case 0: //boat
                    BadGuys[BadGuys.Count-1].Character.Delete();
                    BadGuys.RemoveAt(BadGuys.Count-1);

                    var boatModel = new Model(VehicleHash.Dinghy2);
                    int counter = 0;
                    do
                    {
                        boatModel.Request();
                        //Script.Yield();
                        counter++;
                    } while (!boatModel.IsLoaded && counter < 2000);

                    var boat = World.CreateVehicle(boatModel, new Vector3(-2015.075f, -1040.253f, 0.5699487f), 341.2882f);
                    boat.MarkAsNoLongerNeeded();
                    boat.FreezePosition = true;
                    CleanupBag.Add(boat);
                    foreach (Ped t in team)
                    {
                        t.Position = new Vector3(-2015.249f, -1041.006f, 2.072449f);
                        t.Heading = 63.90365f;
                    }
                    EntryComplete = true;
                    break;
                case 1: // Rappel
                    for (int i = 0; i < Convert.ToInt32(team.Length/2); i++)
                    {
                        var rappel = new RappelEntry(new Vector3(-1492.215f, -1230.166f, 2.87f).Around(20f), new Vector3(-2109.796f, -1009.942f, 22.83442f));
                        var team2 = team.Reverse().ToList();
                        for (int d = 0 + (2*i); d < 2 + (2*i); d++)
                        {
                            Ped t = team2[d];
                            rappel.AddPassenger(t);
                        }
                        rappelUpdates.Add(rappel);
                    }
                    break;

            }
        }
Esempio n. 59
0
 public void StartEntry(int entryPoint, Ped[] team)
 {
     float heading = 0f;
     switch (entryPoint)
     {
         case 0: // Water
             var entryPos = new Vector3(3098.805f, -4801.487f, 2.037071f);
             heading = 14.18145f;
             Ped lastped = new Ped(0);
             for (int index = 0; index < team.Length; index++)
             {
                 team[index].Position = entryPos;
                 if (lastped.Exists()) team[index].Position -= lastped.ForwardVector*2;
                 team[index].Heading = heading;
                 lastped = team[index];
             }
             var enforcermodel = new Model(VehicleHash.Dinghy2);
             enforcermodel.Request(10);
             var enforcer = World.CreateVehicle(enforcermodel, new Vector3(3094.513f, -4802.502f, 0.1324978f), 15.62522f);
             CleanupBag.Add(enforcer);
             EntryComplete = true;
             break;
         case 1: // Plane
             planeEntry = new PlaneEntry(new Vector3(-1598.288f, -2992.517f, 14.87434f), 241.2218f, new Vector3(2541.847f, -3829.26f, 115.3642f),
                 new Vector3(3002.718f, -4602.471f, 15.26161f), new Vector3(3049.975f, -4704.251f, 15.25679f));
             foreach (Ped ped in team)
             {
                 planeEntry.AddPassenger(ped);
             }
             planeEntry.Start();
             break;
         case 2: // Rappel
             Vector3[] rappelpads = new[]
             {
                 new Vector3(-1114.415f, -2884.573f, 14.04894f),
                 new Vector3(-1145.432f, -2864.025f, 14.05568f),
             };
             for (int i = 0; i < Convert.ToInt32(team.Length/2); i++)
             {
                 var rappel = new RappelEntry(rappelpads[i], new Vector3(3079.936f, -4649.66f, 23.87023f));
                 var team2 = team.Reverse().ToList();
                 for (int d = 0 + (2*i); d < 2 + (2*i); d++)
                 {
                     Ped t = team2[d];
                     rappel.AddPassenger(t);
                 }
                 rappelUpdates.Add(rappel);
             }
             break;
     }
 }
Esempio n. 60
0
        private static void SpawnProp(String prop, Vector3 position)
        {
            var model = new Model(prop);
            model.Request(250);

            // Check the model is valid
            if (model.IsInCdImage && model.IsValid)
            {
                // Ensure the model is loaded before we try to create it in the world
                while (!model.IsLoaded)
                {
                    Script.Wait(50);
                }

                // Create the prop in the world
                backpack = World.CreateProp(model, position, true, false);

            }

            // Mark the model as no longer needed to remove it from memory.
            model.MarkAsNoLongerNeeded();
        }