Example #1
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;
            }
        }
Example #2
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);
 }
Example #3
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;
		}
Example #4
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;
        }
Example #5
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();
        }
Example #6
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
            */
        }
        /// <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;
        }
Example #8
0
File: Enemy.cs Project: 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;
 }
Example #9
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));
        }
Example #10
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);
            }
        }
Example #11
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();
        }
Example #12
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);
                }
            }
        }
Example #13
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();
        }
Example #14
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));
        }
Example #15
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;
                    }
                }

            }
        }
Example #16
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
                }
            }
        }
Example #17
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);
        }
 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));
 }
Example #19
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;
        }
Example #20
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();
        }
Example #21
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);
            }
        }
Example #22
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;
            }

            }
        }
Example #23
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;
                    }
                }
            }
        }
Example #24
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();
                }
            }
        }
Example #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();
 }
Example #26
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;
        }
Example #27
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();
                }
            }
        }
Example #28
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;

            }
        }
Example #29
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;
     }
 }
Example #30
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;

            }
        }