//public Hash end_street;

            public void activate()
            {
                blip?.Remove();
                blip = World.CreateBlip(start);
                blip.Color = BlipColor.Green;
                isActive = true;
            }
Beispiel #2
0
        void MOD_KeyDown(object sender, GTA.KeyEventArgs e)
        {
            inputCheckerMOD.AddInputKey(e.Key);

            if (inputCheckerMOD.Check(1))
            {
                //ActiveFlag = true;
            }

            if (inputCheckerMOD.Check(0) == true)
            {
                if (ActiveFlag)
                {
                    ActiveFlag = false;
                    KamikazeFlag = false;
                    if (Exists(KB)) { KB.Delete(); }
                    KB = Blip.AddBlip(K_P);
                    Game.DisplayText("Kamikaze OFF", 4000);
                }
                else
                {
                    ActiveFlag = true;

                    Game.DisplayText("Kamikaze ON", 4000);
                }
            }
        }
 /// <summary>
 /// Create destinationblip
 /// </summary>
 public void createDestinationBlip()
 {
     destinationBlip = World.CreateBlip( destination );
     destinationBlip.Sprite = BlipSprite.Crosshair;
     destinationBlip.Color = BlipColor.Green;
     destinationBlip.IsFlashing = true;
     destinationBlip.ShowRoute = true;
     destinationBlip.Position = destination;
 }
Beispiel #4
0
        protected override void depopulateDestructibleElements(bool removePhysicalElements = false)
        {
            if ( this.destinationBlip != null) {
                this.destinationBlip.Remove();
                this.destinationBlip = null;
            }

            if ( this.finishCheckpoint != -1) {
                Function.Call( Hash.DELETE_CHECKPOINT, this.finishCheckpoint );
                this.finishCheckpoint = -1;
            }
        }
Beispiel #5
0
        public static void TeleportToWaypoint()
        {
            Blip wpBlip = new Blip(Function.Call<int>(Hash.GET_FIRST_BLIP_INFO_ID, 8));

            if (Function.Call<bool>(Hash.IS_WAYPOINT_ACTIVE))
            {
                GTA.Math.Vector3 wpVec = Function.Call<GTA.Math.Vector3>(Hash.GET_BLIP_COORDS, wpBlip);
                Game.Player.Character.Position = wpVec;
            }
            else
            {
                UI.ShowSubtitle("Waypoint not active.");
            }
        }
        public void SetAutopilot(bool toggle)
        {
            if (toggle)
            {
                if (!Function.Call<bool>(Hash.IS_WAYPOINT_ACTIVE))
                    return;

                var wpBlip = new Blip(Function.Call<int>(Hash.GET_FIRST_BLIP_INFO_ID, 8));
                var wpVec = Function.Call<Vector3>(Hash.GET_BLIP_COORDS, wpBlip);
                Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, vehicle.GetPedOnSeat(VehicleSeat.Driver), vehicle, wpVec.X, wpVec.Y, wpVec.Z + 150f, vehicle.Speed, 1, vehicle.Model.Hash, 262144, -1.0, -1.0);
            }
            else
                vehicle.GetPedOnSeat(VehicleSeat.Driver).Task.ClearAll();
        }
Beispiel #7
0
        /// <summary>
        /// Populate objective elements
        /// </summary>
        protected override void populateDestructibleElements()
        {
            base.populateDestructibleElements();

            destinationBlip = World.CreateBlip(destination);
            destinationBlip.Sprite = BlipSprite.Crosshair;
            destinationBlip.Color = BlipColor.Green;
            destinationBlip.IsFlashing = true;
            destinationBlip.ShowRoute = true;
            destinationBlip.Position = destination;

            this.finishCheckpoint = Function.Call<int>(Hash.CREATE_CHECKPOINT, 24, this.destination.X, this.destination.Y, 0.0f, this.destination.X, this.destination.Y, 0.0f, 2f, 254, 207, 12, 200, 40);
            Function.Call(Hash._SET_CHECKPOINT_ICON_RGBA, this.finishCheckpoint, 0, 0, 256, 60);
            Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, this.finishCheckpoint, Tools.GetGroundedPosition( this.destination ).Z + 30.0f, Tools.GetGroundedPosition( this.destination ).Z + 30.0f, 30.0f);
        }
Beispiel #8
0
        public Vector3 GetWaypointCoords()
        {
            Vector3 wpVec = new Vector3();
            Blip wpBlip = new Blip(Function.Call<int>(Hash.GET_FIRST_BLIP_INFO_ID, 8));

            if (Function.Call<bool>(Hash.IS_WAYPOINT_ACTIVE))
            {
                wpVec = Function.Call<GTA.Math.Vector3>(Hash.GET_BLIP_COORDS, wpBlip);
            }
            else
            {
                UI.ShowSubtitle("Waypoint not set!");
            }
            return wpVec;
        }
Beispiel #9
0
        void TestScript1_Tick(object sender, EventArgs e)
        {
            Pickup.CreatePickup(new Vector3(1.23f, 1.23f, 1.23f), WeaponID.Assault_AK47, 500);

            if (myPed == null)
            {
                myPed = World.CreatePed(PedID.WFYSEX, Player.Character.Position.Around(10), 23);
                myBlip = Blip.AddBlip(myPed);
                myBlip.Color = BlipColor.Pickup;

                Player.Character.Weapons[WeaponID.Assault_M4].Load();
                Player.Character.Weapons[WeaponID.Assault_M4].Ammo = 200;
                Player.Character.Weapons[WeaponID.Assault_M4].Select();
            }

            if (!myPed.IsAlive)
            {
                myBlip.Delete();
                myPed = null;
            }
        }
Beispiel #10
0
        void TestScript1_Tick(object sender, EventArgs e)
        {
            Pickup.CreatePickup(new Vector3(1.23f, 1.23f, 1.23f), WeaponID.Assault_AK47, 500);

            if (myPed == null)
            {
                myPed        = World.CreatePed(PedID.WFYSEX, Player.Character.Position.Around(10), 23);
                myBlip       = Blip.AddBlip(myPed);
                myBlip.Color = BlipColor.Pickup;

                Player.Character.Weapons[WeaponID.Assault_M4].Load();
                Player.Character.Weapons[WeaponID.Assault_M4].Ammo = 200;
                Player.Character.Weapons[WeaponID.Assault_M4].Select();
            }

            if (!myPed.IsAlive)
            {
                myBlip.Delete();
                myPed = null;
            }
        }
        public void OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F2)
                foreach (var v in World.GetNearbyVehicles(Game.Player.Character.Position, 10))
                    v.Delete();

            if (e.KeyCode == Keys.K)
                Function.Call(Hash.SET_TIME_SCALE, 1.0f);
            if (e.KeyCode == Keys.F3)
                Game.Player.Character.Position = _busPosition;

            if (e.KeyCode == Keys.J && _isTransitioning)
            {
                _driver.Delete();
                Game.Player.Character.SetIntoVehicle(Game.Player.Character.CurrentVehicle, VehicleSeat.Driver);
                Function.Call(Hash.SET_TIME_SCALE, 1f);
                _isTransitioning = false;
            }

            if (e.KeyCode == Keys.F && World.GetDistance(Game.Player.Character.Position, _startPosition) < 2f &&
                !_activateMod)
            {
                //Check for previous spawned busses
                foreach (var b in World.GetActiveBlips().Where(b => (b.Color == BlipColor.Blue)))
                    b.Remove();
                foreach (
                    var v in
                        World.GetAllVehicles().Where(v => (v.GetPedOnSeat(VehicleSeat.Driver).Model == "A_C_Chimp")))
                    v.Delete();
                _activateMod = true;
                _bus = World.CreateVehicle("Bus", _busPosition);
                _driver =_bus.CreatePedOnSeat(VehicleSeat.Driver, new Model("A_C_Chimp"));
                _busBlip = _bus.AddBlip();
                _busBlip.Color = BlipColor.Blue;
                _busBlip.Name = "Bus";
                _busBlip.ShowRoute = _busBlip.IsFriendly = true;
            }
        }
	    public void OnTick(object sender, EventArgs e)
	    {
		    if (DateTime.Now.Second != _lasttime.Second)
		    {
			    _seconds++;
			    _lasttime = DateTime.Now;
			    if (_isInRace && _countdown > 0)
			    {
				    var screen = UIMenu.GetScreenResolutionMantainRatio();
				    var w = Convert.ToInt32(screen.Width/2);
				    _countdown--;
					if(_countdown > 3) return;
				    _fadeoutSprite = new Sprite("mpinventory", "in_world_circle", new Point(w - 125, 200), new Size(250, 250), 0f, _countdown == 0 ? Color.FromArgb(49, 235, 126) : Color.FromArgb(241, 247, 57));
					Function.Call(Hash.REQUEST_SCRIPT_AUDIO_BANK, "HUD_MINI_GAME_SOUNDSET", true);
					Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_NORMAL", "HUD_MINI_GAME_SOUNDSET");
					if (_countdown == 0)
				    {
					    _participants.ForEach(car => car.FreezePosition = false);
					    _missionStart = _seconds;
				    }
			    }
				else if (_isInRace && _countdown == 0)
				{
					_countdown = -1;
				}
		    }

			GUI.MainMenu.ProcessControl();
			GUI.MainMenu.ProcessMouse();
			GUI.MainMenu.Draw();

			_quitMenu.ProcessControl();
			_quitMenu.ProcessMouse();
			_quitMenu.Draw();

			GUI.DrawSettings(_previewRace, _previewVehicle);

			_passed?.Draw();

			if (_countdown > -1 && _countdown <= 3)
		    {
				var screen = UIMenu.GetScreenResolutionMantainRatio();
				var w = Convert.ToInt32(screen.Width / 2);
				new UIResText(_countdown == 0 ? "GO" : _countdown.ToString(), new Point(w, 260), 2f, Color.White, Font.Pricedown, UIResText.Alignment.Centered).Draw();
		    }

		    if (_fadeoutSprite?.Color.A > 5)
		    {
			    _fadeoutSprite.Color = Color.FromArgb(_fadeoutSprite.Color.A - 5, _fadeoutSprite.Color.R, _fadeoutSprite.Color.G,
				    _fadeoutSprite.Color.B);
				_fadeoutSprite.Draw();
		    }


            /* COURIER */
            GUICourier.Init();
            GUICourier.MainMenu.ProcessControl();
            GUICourier.MainMenu.ProcessMouse();
            var safe = UIMenu.GetSafezoneBounds();
            var res = UIMenu.GetScreenResolutionMantainRatio();

            new UIResRectangle(new Point(((int)res.Width-200), 0), new Size(200, 400), Color.FromArgb(200,0,0,0)).Draw();

            GUICourier.MainMenu.Draw();

            if (activeDeliveries.Count == 0 || (_seconds - lastSpawn > 60 && activeDeliveries.Count < 3))
            {
                Delivery d = Delivery.CreateDelivery();
                d.activate();
                activeDeliveries.Add(d);
                lastSpawn = _seconds;
                UI.Notify("New delivery available");
            }

            int pick = 0,drop = 0;
            Vector3 me = Game.Player.Character.Position;
            String posStr = String.Format("{0} {1} {2}", me.X.ToString("F02"), me.Y.ToString("F02"), me.Z.ToString("F02"));


            new UIResText("Pickup", new Point(Convert.ToInt32(res.Width) - 190, 20), .45f, Color.White, Font.HouseScript, UIResText.Alignment.Left) { DropShadow = true }.Draw();
            new UIResText("Dropoff", new Point(Convert.ToInt32(res.Width) - 190, 210), .45f, Color.White, Font.HouseScript, UIResText.Alignment.Left) { DropShadow = true }.Draw();
            foreach (Delivery d in activeDeliveries.GetRange(0,activeDeliveries.Count)) {
                d.tick();
                if (d.isActive == false)
                {
                    activeDeliveries.Remove(d);
                    continue;
                }

 
                if (d._isStarted)
                {
                    float dist = me.DistanceTo(d.end);
                    String posStr2 = String.Format("{0} {1} {2}", d.end.X.ToString("F02"), d.end.Y.ToString("F02"), d.end.Z.ToString("F02"));
                    new UIResText(String.Format("{0} {1}", dist.ToString("F02"), d.end_text), new Point(Convert.ToInt32(res.Width) - 190, 20 * (drop + 2) + 210), .35f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true }.Draw();

                    drop++;
                }
                else {
                    float dist = me.DistanceTo(d.start);
                    String posStr2 = String.Format("{0} {1} {2}", d.start.X.ToString("F02"), d.start.Y.ToString("F02"), d.start.Z.ToString("F02"));
                    new UIResText(String.Format("{0} {1}", dist.ToString("F02"), d.start_text), new Point(Convert.ToInt32(res.Width) - 190, 20 * (pick + 2)), .35f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true }.Draw();

                    pick++;
                }
                //new UIResText("WORLD", new Point(Convert.ToInt32(res.Width) - 190, 40), .35f, Color.DodgerBlue, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true }.Draw();

            }
            /* COURIER */

            if (!_isInRace)
		    {
				if(GUI.IsInMenu) return;
			    foreach (var race in _races)
			    {
				    World.DrawMarker(MarkerType.VerticalCylinder, race.Trigger, new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(5f, 5f, 1f), Color.FromArgb(200, 255, 255, 255));
					if(!Game.Player.Character.IsInRangeOf(race.Trigger, 50f)) continue;
				    var tmpSF = new Scaleform(0);
				    tmpSF.Load("PLAYER_NAME_01");
					tmpSF.CallFunction("SET_PLAYER_NAME", race.Name);
				    
					tmpSF.Render3D(race.Trigger + new Vector3(0f, 0f, 2f), new Vector3(0f, 0f, _oldAngle), new Vector3(12, 6, 2));

					var tmpT = new Scaleform(0);
					tmpT.Load("PLAYER_NAME_02");
					tmpT.CallFunction("SET_PLAYER_NAME", "Community Race");

					tmpT.Render3D(race.Trigger + new Vector3(0f, 0f, 1.5f), new Vector3(0f, 0f, _oldAngle), new Vector3(6, 3, 1));

					_oldAngle += 2f;

                    if (!Game.Player.Character.IsInRangeOf(race.Trigger, 5f)) continue;

                    Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
                    Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, "Press ~INPUT_CONTEXT~ to participate in this Community Race.");
                    Function.Call(Hash._0x238FFE5C7B0498A6, 0, 0, 1, -1);

                    if (Game.IsControlJustPressed(0, GTA.Control.Context))
				    {
					    Game.Player.CanControlCharacter = false;
					    Game.Player.Character.Position = race.Trigger + new Vector3(4f, 0f, -1f);
					    _previewRace = race;
						BuildMenu(race);
					    GUI.MainMenu.Visible = true;
					    GUI.IsInMenu = true;
					    break;
				    }
			    }
				
		    }
		    else if(_isInRace)
		    {
				if(!_raceSettings["Wanted"])
					Function.Call(Hash.SET_MAX_WANTED_LEVEL, 0);
				//if(Game.Player.Character.IsInVehicle())
				Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)GTA.Control.VehicleExit);
			    if ((Game.IsControlJustPressed(0, GTA.Control.VehicleExit) && Game.Player.Character.IsInVehicle()) || (!Game.Player.Character.IsInVehicle() && !Game.Player.Character.IsGettingIntoAVehicle && Game.IsControlJustPressed(0, GTA.Control.Enter)))
			    {
					_quitMenu.RefreshIndex();
				    _quitMenu.Visible = !_quitMenu.Visible;
			    }
				
			    if (!Convert.ToBoolean(_raceSettings["Traffic"]))
			    {
				    Vehicle[] close = World.GetNearbyVehicles(Game.Player.Character, 10000f);
				    foreach (Vehicle vehicle in close)
				    {
					    if (_currentRivals.Any(riv => riv.Vehicle.Handle == vehicle.Handle) ||
					        Game.Player.Character.IsInVehicle(vehicle)) continue;
						vehicle.GetPedOnSeat(VehicleSeat.Driver)?.Delete();
						vehicle?.Delete();
				    }
			    }

			//    var res = UIMenu.GetScreenResolutionMantainRatio();
			//    var safe = UIMenu.GetSafezoneBounds();
			    const int interval = 45;
			    if (_countdown <= 0)
			    {
				    new UIResText("TIME",new Point(Convert.ToInt32(res.Width) - safe.X - 180, Convert.ToInt32(res.Height) - safe.Y - (90 + (1*interval))),0.3f, Color.White).Draw();
				    new UIResText(FormatTime((int) unchecked(_seconds - _missionStart)),new Point(Convert.ToInt32(res.Width) - safe.X - 20, Convert.ToInt32(res.Height) - safe.Y - (102 + (1*interval))),0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
				    new Sprite("timerbars", "all_black_bg",new Point(Convert.ToInt32(res.Width) - safe.X - 248,Convert.ToInt32(res.Height) - safe.Y - (100 + (1*interval))), new Size(250, 37), 0f, Color.FromArgb(200, 255, 255, 255)).Draw();

					new UIResText("POSITION", new Point(Convert.ToInt32(res.Width) - safe.X - 180, Convert.ToInt32(res.Height) - safe.Y - (90 + (2 * interval))), 0.3f, Color.White).Draw();
					new UIResText((CalculatePlayerPositionInRace() + 1) + "/" + (_currentRivals.Count + 1), new Point(Convert.ToInt32(res.Width) - safe.X - 20, Convert.ToInt32(res.Height) - safe.Y - (102 + (2 * interval))), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
					new Sprite("timerbars", "all_black_bg", new Point(Convert.ToInt32(res.Width) - safe.X - 248, Convert.ToInt32(res.Height) - safe.Y - (100 + (2 * interval))), new Size(250, 37), 0f, Color.FromArgb(200, 255, 255, 255)).Draw();

				    if (_raceSettings["Laps"] > 1)
				    {
						int playerCheckpoint = _currentRace.Checkpoints.Length - _checkpoints.Count;
					    int currentLap = Convert.ToInt32(Math.Floor(playerCheckpoint/(decimal)_totalLaps)) + 1;

						new UIResText("LAP",new Point(Convert.ToInt32(res.Width) - safe.X - 180,Convert.ToInt32(res.Height) - safe.Y - (90 + (3*interval))), 0.3f, Color.White).Draw();
					    new UIResText(currentLap + "/" + _raceSettings["Laps"], new Point(Convert.ToInt32(res.Width) - safe.X - 20,Convert.ToInt32(res.Height) - safe.Y - (102 + (3*interval))), 0.5f, Color.White, Font.ChaletLondon,UIResText.Alignment.Right).Draw();
					    new Sprite("timerbars", "all_black_bg",new Point(Convert.ToInt32(res.Width) - safe.X - 248,Convert.ToInt32(res.Height) - safe.Y - (100 + (3*interval))), new Size(250, 37), 0f,Color.FromArgb(200, 255, 255, 255)).Draw();
				    }
			    }


			    for (int i = 0; i < _rivalCheckpointStatus.Count; i++)
			    {
				    Tuple<Rival, int> tuple = _rivalCheckpointStatus[i];
				    if (tuple.Item1.Vehicle.IsInRangeOf(_currentRace.Checkpoints[tuple.Item2], 10f))
				    {
					    tuple.Item1.Character.Task.ClearAll();
					    if (_currentRace.Checkpoints.Length <= tuple.Item2 + 1)
					    {
						    if (!_finishedParticipants.Contains(tuple.Item1))
							    _finishedParticipants.Add(tuple.Item1);
						    tuple.Item1.Vehicle.HandbrakeOn = true;
						    continue;
					    }
					    _rivalCheckpointStatus[i] = new Tuple<Rival, int>(tuple.Item1,tuple.Item2 + 1);
					    Function.Call(Hash.TASK_VEHICLE_MISSION_COORS_TARGET, tuple.Item1.Character.Handle, tuple.Item1.Vehicle.Handle,
						    _currentRace.Checkpoints[tuple.Item2 + 1].X, _currentRace.Checkpoints[tuple.Item2 + 1].Y,
						    _currentRace.Checkpoints[tuple.Item2 + 1].Z, Mode, 200f, Rival.MainDrivingStyle, 5f, 0f, 0); // TODO: Debuggin // old - 6
				    }
			    }


			    World.DrawMarker(MarkerType.VerticalCylinder, _checkpoints[0], new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(10f, 10f, 2f), Color.FromArgb(100, 241, 247, 57));
			    if (_nextBlip == null)
				    _nextBlip = World.CreateBlip(_checkpoints[0]);
			    if (_checkpoints.Count >= 2)
			    {
				    if (_secondBlip == null)
				    {
					    _secondBlip = World.CreateBlip(_checkpoints[1]);
					    _secondBlip.Scale = 0.5f;
						if(_checkpoints.Count == 2)
							_secondBlip.Sprite = BlipSprite.RaceFinish;
				    }
				    Vector3 dir = _checkpoints[1] - _checkpoints[0];
					dir.Normalize();
					World.DrawMarker(MarkerType.ChevronUpx1, _checkpoints[0] + new Vector3(0f, 0f, 2f), dir, new Vector3(60f, 0f, 0f), new Vector3(4f, 4f, 4f), Color.FromArgb(200, 87, 193, 250));
			    }
			    else
			    {
					Vector3 dir = Game.Player.Character.Position - _checkpoints[0];
					dir.Normalize();
				    World.DrawMarker(MarkerType.CheckeredFlagRect, _checkpoints[0] + new Vector3(0f, 0f, 2f), dir, new Vector3(0f, 0f, 0f), new Vector3(4f, 4f, 4f), Color.FromArgb(200, 87, 193, 250));
					_nextBlip.Sprite = BlipSprite.RaceFinish;
			    }

			    if (Game.Player.Character.IsInVehicle() && Game.Player.Character.IsInRangeOf(_checkpoints[0], 10f))
			    {
					Function.Call(Hash.REQUEST_SCRIPT_AUDIO_BANK, "HUD_MINI_GAME_SOUNDSET", true);
					Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_NORMAL", "HUD_MINI_GAME_SOUNDSET");
					_checkpoints.RemoveAt(0);
					_nextBlip?.Remove();
					_secondBlip?.Remove();
				    _nextBlip = null;
				    _secondBlip = null;
				    if (_checkpoints.Count == 0)
				    {
					    Game.Player.CanControlCharacter = false;
						Function.Call(Hash._START_SCREEN_EFFECT, "HeistCelebPass", 0, true);
						if(Game.Player.Character.IsInVehicle())
							Game.Player.Character.CurrentVehicle.HandbrakeOn = true;
						World.DestroyAllCameras();
					    World.RenderingCamera = World.CreateCamera(GameplayCamera.Position, GameplayCamera.Rotation, 60f);
						Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_UNDER_THE_BRIDGE", "HUD_MINI_GAME_SOUNDSET");
						int position = _finishedParticipants.Count + 1;
					    int peoplecount = _currentRivals.Count + 1;
					    int score = 100 - ((position - 1)*10);
					    if (score < 0)
						    score = 0;
						_passed = new MissionPassedScreen(_currentRace.Name, score, score > 50 ? score > 90 ? MissionPassedScreen.Medal.Gold : MissionPassedScreen.Medal.Silver : MissionPassedScreen.Medal.Bronze);
						_passed.AddItem("Time Elapsed", FormatTime((int)unchecked(_seconds - _missionStart)), MissionPassedScreen.TickboxState.None);
						_passed.AddItem("Position", position + "/" + peoplecount, position == 1 ? MissionPassedScreen.TickboxState.Tick : MissionPassedScreen.TickboxState.Empty);
					    _passed.OnContinueHit += () =>
					    {
							Game.FadeScreenOut(1000);
							Wait(1000);
							Function.Call(Hash._STOP_SCREEN_EFFECT, "HeistCelebPass");
						    Game.Player.Character.Position = _currentRace.Trigger;
						    Game.Player.CanControlCharacter = true;
						    World.RenderingCamera = null;
							EndRace();
						    _passed = null;
							Game.FadeScreenIn(1500);
					    };
						_passed.Show();
						_isInRace = false;
				    }
			    }
			}
	    }
 public void hit()
 {
     if (Game.Player.Character.IsInRangeOf(start, 3f) && !_isStarted)
     {
         UI.Notify("Picked up package");
         _isStarted = true;
         blip?.Remove();
         blip = World.CreateBlip(end);
         blip.Color = BlipColor.Red;
     }
     if (Game.Player.Character.IsInRangeOf(end, 3f) && _isStarted)
     {
         _isStarted = false;
         UI.Notify("Finished!");
         Game.Player.Money += RandGen.Next(2,5);
         blip.Remove();
         isActive = false;
     }
 }
        private void OnTick(object sender, EventArgs e)
        {
            if (Game.Player.Character.IsInVehicle() || Game.Player.Character.IsSittingInVehicle()) {
                var v = Game.Player.Character.CurrentVehicle;
                if (_godEnabled) {
                    v = new Vehicle(GTAFuncs.RequestEntityControl(v).Handle);
                    if(v != null) {
                        v.BodyHealth = v.MaxHealth;
                        v.EngineHealth = v.MaxHealth;
                        v.PetrolTankHealth = v.MaxHealth;
                        v.Health = v.MaxHealth;
                        v.CanBeVisiblyDamaged = false;
                    }
                    GTAFuncs.SetEntityInvinc(v, true);
                }
                else GTAFuncs.SetEntityInvinc(v, false);
            }

            if (_godEnabled) Game.Player.Character.Health = Game.Player.Character.MaxHealth;

            GTAFuncs.SetInvincTime(_godEnabled ? 30000 : 0);
            GTAFuncs.SetSPInvinc(_player, _godEnabled);

            if (GTAFuncs.IsWaypointActive())
                _lastWaypoint = new Blip(GTAFuncs.GetFirstBlipInfoID((int) BlipSprite.Waypoint));

            if (_noClipEnabled) {
                Game.Player.Character.Rotation = GameplayCamera.Rotation;

                GTAFuncs.SetEntityGravity(Game.Player.Character, false);
                GTAFuncs.SetEntityLoadColissionFlag(Game.Player.Character, false);
                GTAFuncs.SetEntityRecordsCollisions(Game.Player.Character, false);
                GTAFuncs.SetEntityCollision(Game.Player.Character, false, false);
                GTAFuncs.DisableControlAction(Control.MoveUp, true);
                GTAFuncs.DisableControlAction(Control.MoveDown, true);
                GTAFuncs.DisableControlAction(Control.MoveLeft, true);
                GTAFuncs.DisableControlAction(Control.MoveRight, true);
                GTAFuncs.DisableControlAction(Control.Attack, true);
                GTAFuncs.DisableControlAction(Control.Aim, true);

                var v = new Vector3(0, 0, 0);

                if (Game.Player.Character.IsInVehicle() || Game.Player.Character.IsSittingInVehicle())
                    Game.Player.Character.Position = Game.Player.Character.Position;

                if (GTAFuncs.GetControlNormal(Control.MoveUp) != 0) {
                    v += Vector3.Multiply(Game.Player.Character.ForwardVector,
                        -25*GTAFuncs.GetControlNormal(Control.MoveUp));
                }
                if (GTAFuncs.GetControlNormal(Control.MoveRight) != 0) {
                    v += Vector3.Multiply(Game.Player.Character.RightVector,
                        25*GTAFuncs.GetControlNormal(Control.MoveRight));
                }
                if (GTAFuncs.IsControlPressed(Control.Attack)) {
                    v += Vector3.Multiply(Game.Player.Character.UpVector, 15);
                }
                if (GTAFuncs.IsControlPressed(Control.Aim)) {
                    v += Vector3.Multiply(Game.Player.Character.UpVector, -15);
                }

                Game.Player.Character.Velocity = v;
            }
            else {
                GTAFuncs.EnableControlAction(Control.MoveUp, true);
                GTAFuncs.EnableControlAction(Control.MoveDown, true);
                GTAFuncs.EnableControlAction(Control.MoveLeft, true);
                GTAFuncs.EnableControlAction(Control.MoveRight, true);
                GTAFuncs.EnableControlAction(Control.Attack, true);
                GTAFuncs.EnableControlAction(Control.Aim, true);
                GTAFuncs.SetEntityGravity(Game.Player.Character, true);
                GTAFuncs.SetEntityLoadColissionFlag(Game.Player.Character, true);
                GTAFuncs.SetEntityRecordsCollisions(Game.Player.Character, true);
                GTAFuncs.SetEntityCollision(Game.Player.Character, true, true);
            }

            if (_forceFieldEnabled) {
                GTAFuncs.ClearAreaOfObjects(Game.Player.Character.Position, 100);
                GTAFuncs.ClearAreaOfProjectiles(Game.Player.Character.Position, 100);

                foreach (var _ent in World.GetAllEntities()) {
                    var ent = _ent;
                    if (ent.Handle == Game.Player.Character.Handle || GTAFuncs.GetPlayerEntity(Game.Player).Handle == ent.Handle) continue;

                    if (ent.Position.DistanceTo(Game.Player.Character.Position) <= 100) {
                        if (GTAFuncs.GetEntityType(ent) == GTAFuncs.EntityType.Ped && new Ped(ent.Handle).IsPlayer) {
                            Player player = GTAFuncs.GetPedPlayer(new Ped(ent.Handle));
                            ent = GTAFuncs.RequestEntityControl(player, 1);
                            GTAFuncs.ActivateDamageTrackerOnNetworkId(GTAFuncs.GetNetworkID(player), true);
                        }
                        else GTAFuncs.RequestEntityControl(ent, 1);

                        if (ent.IsAttached()) {
                            ent.Detach();
                            ent.Delete();
                        } else {
                            GTAFuncs.SetEntityInvinc(ent, false);
                            Vector3 vel = (Game.Player.Character.Position - ent.Position);
                            vel.Normalize();
                            vel *= -1000;
                            ent.Velocity = vel + new Vector3(0, 0, 100);
                        }
                    }

                }
            }

            if (_developerConsole.Debug && ConsoleSettings.IsDevBuild) GTAFuncs.AntiBan();
        }
Beispiel #15
0
        private void MOD_Tick(object sender, EventArgs e)
        {
            if (ActiveFlag)
            {
                ///-------------------------------------------------------------
                if (KamikazeFlag)
                {
                    if (K_P.DistanceTo(S_P) > 100.0f)
                    {
                        if (Exists(KB)) { KB.Delete(); }
                        KamikazeFlag = false;
                        Player.Character.Invincible = false;
                    }
                    else
                    {

                        if (Exists(peds[pedIndex]) && peds[pedIndex] != Player.Character)
                        {
                            Vector3 Force = K_P - peds[pedIndex].Position;
                            Force.Normalize();

                            Force = RotationVector(Force, 20.0f);////////////////////

                            Force = 20.0f * Force;
                            peds[pedIndex].ApplyForce(Force);
                        }
                        if (Exists(vehs[vehIndex]) && vehs[vehIndex] != Player.Character.CurrentVehicle)
                        {
                            Vector3 Force = K_P - vehs[vehIndex].Position;
                            Force.Normalize();

                            Force = RotationVector(Force, 20.0f);//////////////

                            Force = 50.0f * Force;
                            vehs[vehIndex].ApplyForce(Force);
                        }

                        pedIndex = (pedIndex + 1) % peds.Length;
                        vehIndex = (vehIndex + 1) % vehs.Length;

                    }

                    K_P += Speed * K_D;
                    if (Exists(KB)) { KB.Delete(); }
                    KB = Blip.AddBlip(K_P);

                }
                else
                {
                    if (Exists(KB)) { KB.Delete(); }
                    KB = Blip.AddBlip(K_P);
                    if (Player.Character.Weapons.Current == Weapon.Melee_BaseballBat || true)
                    {
                        if (Game.isGameKeyPressed(GameKey.Reload))
                        {
                            Game.DisplayText("神風だ!", 4000);

                            K_P = Player.Character.Position;
                            S_P = K_P;
                            float theata = (Player.Character.Heading + 90.0f) * (float)Math.PI / 180.0f;
                            K_D = new Vector3((float)Math.Cos(theata), (float)Math.Sin(theata), 0);
                            K_D.Normalize();

                            peds = World.GetPeds(K_P, 400.0f);
                            vehs = World.GetVehicles(K_P, 400.0f);
                            pedIndex = 0;
                            vehIndex = 0;
                            Player.Character.Invincible = true;
                            KamikazeFlag = true;

                        }
                    }
                }

                ///------------------------------------------------------------------
            }
        }
        public void prison_escape_tick()
        {
            if (steps == 0)
                {
                    if (Game.Player.Character.IsInVehicle(escape_veh1))
                    {
                        vehb.Remove();
                        vehb = escape_veh2.AddBlip();
                        vehb.Color = BlipColor.Yellow;
                        vehb.ShowRoute = true;
                        UI.ShowSubtitle("Go to the Meeting",3000);
                        steps = 1;
                    }
                }
                if (steps == 1)
                {
                    if (Game.Player.Character.Position.DistanceTo(escape_veh2.Position) < 100f)
                    {
                        vehb.Color = BlipColor.Blue;
                        vehb.ShowRoute = false;
                        UI.ShowSubtitle("Enter the ~b~ Vehicle");

                        int pgroupe = Game.Player.Character.RelationshipGroup;
                        escape_ped1.RelationshipGroup = pgroupe;
                        GiveAllWeapons(escape_ped1);
                        escape_ped1.CanSwitchWeapons = true;

                        escape_ped2.RelationshipGroup = pgroupe;
                        GiveAllWeapons(escape_ped2);
                        escape_ped2.CanSwitchWeapons = true;

                        original_ped.RelationshipGroup = pgroupe;
                        GiveAllWeapons(original_ped);
                        original_ped.CanSwitchWeapons = true;

                        escape_ped2.Task.EnterVehicle(escape_veh2, VehicleSeat.Passenger, 5000);
                        steps = 2;
                    }
                }
                if (steps == 2)
                {
                    escape_veh1.MarkAsNoLongerNeeded();
                    if (Game.Player.Character.IsInVehicle(escape_veh2) && escape_ped2.IsInVehicle(escape_veh2))
                    {
                        vehb.Remove();
                        escape_veh3.Position = new Vector3(-1179.25f, -2845.386f, 13.5665f);
                        escape_veh3.Heading = 325.6199f;
                        vehb = escape_veh3.AddBlip();
                        vehb.Color = BlipColor.Blue;
                        UI.ShowSubtitle("Steel the ~b~ Valkyrie ~w~ from ~r~ Airport", 3000);
                        steps = 3;
                    }
                }

                if (steps == 3)
                {
                        if (Game.Player.Character.IsInVehicle(escape_veh3))
                        {
                            vehb.Remove();
                            escape_ped2.Task.EnterVehicle(escape_veh3, VehicleSeat.RightRear, 5000);
                            steps = 4;
                        }
                }
                if (steps == 4)
                {
                    if (Game.Player.Character.IsInVehicle(escape_veh3))
                    {
                        if (escape_ped2.IsInVehicle(escape_veh3))
                        {
                            UI.ShowSubtitle("");
                            vehb = World.CreateBlip(new Vector3(1649.463f, 2619.634f, 45.56486f));
                            vehb.Color = BlipColor.Yellow;
                            vehb.ShowRoute = true;
                            UI.Notify("You can change between you and your partner with ~g~ [E] ~w~ do not use the game Character switche");
                            original_ped.Task.GoTo(new Vector3(1649.463f, 2619.634f, 45.56486f));
                            escape_veh2.MarkAsNoLongerNeeded();
                            steps = 5;
                        }
                        else
                        UI.ShowSubtitle("Wait for the you partner to enter the Valkyrie");
                    }
                    else
                    {
                        UI.ShowSubtitle("Enter to the Valkyrie");
                    }

                }
                if(steps == 5)
                {
                    if (Game.Player.Character.Position.DistanceTo(new Vector3(1649.463f, 2619.634f, 45.56486f))<50f)
                    {
                        if (current_ped == 2)
                        {
                            Function.Call(Hash.CHANGE_PLAYER_PED, Game.Player, escape_ped1, 1, 0);
                            steps = 6;
                        }
                    }
                }
                if (steps == 6)
                {
                    if (escape_veh3.IsOnAllWheels && Game.Player.Character.Position.DistanceTo(new Vector3(1649.463f, 2619.634f, 45.56486f)) < 50f)
                    {
                        vehb.Remove();

                        original_ped.Task.EnterVehicle(escape_veh3, VehicleSeat.LeftRear, 1000);
                        UI.ShowSubtitle("wait for the prisonier");
                        steps = 7;
                    }
                }
                if (steps == 7)
                {
                    if (original_ped.IsInVehicle(escape_veh3))
                    {
                        UI.ShowSubtitle("escape the police",5000);
                        vehb.Remove();
                        steps = 8;
                    }
                }

                if (Game.Player.WantedLevel == 0 && steps == 8)
                {
                    UI.ShowSubtitle("you have escaped");
                    player_status = status.Off;
                    escape = false;
                    arrested = false;
                    inprison = false;
                    bail.Remove();
                    roit.Remove();
                    vehb.Remove();

                }
        }
Beispiel #17
0
 public void AddBlip(BlipColor color)
 {
     blip = World.CreateBlip(Position);
     blip.Color = color;
 }
Beispiel #18
0
 public void clearBlip(Blip blip)
 {
 }
 /// <summary>
 /// Remove destinationblip and set the value to null
 /// </summary>
 private void removeDestinationBlip()
 {
     if ( this.destinationBlip != null ) {
         this.destinationBlip.Remove();
     }
     this.destinationBlip = null;
 }
        public void CallMechanic( Vehicle vehicle, Engine vehicleEngine )
        {
            if ( this._isCalled )
            {
                UI.Notify( "Mechanic is already called!", true );
                return;
            }
            if ( Math.Round( vehicle.Speed, 2 ) > 0 )
            {
                UI.Notify( "You should stop your car before calling the mechanic!", true );
                return;
            }
            if ( !this.TakeMoney() )
            {
                UI.Notify( "Not enought money!", true );
                return;
            }

            vehicle.IsDriveable = false;
            var vehiclePosition = vehicle.Position;
            var spawnPosition = World.GetNextPositionOnStreet( vehiclePosition.Around( 80f ) );

            this._mechanicVehicle = World.CreateVehicle( VehicleHash.Panto, spawnPosition );
            this._mechanicPed = this._mechanicVehicle.CreatePedOnSeat( VehicleSeat.Driver, PedHash.FatWhite01AFM );
            this._mechanicPed.Weapons.Give( WeaponHash.FireExtinguisher, 10000, true, true );

            var openHoodPosition = vehicle.GetOffsetInWorldCoords( new Vector3( 0.35f, 3.0f, 0.0f ) );
            var shootPosition = vehicle.GetOffsetInWorldCoords( new Vector3( 0.35f, 5.0f, 0.0f ) );

            var tasks = new TaskSequence();
            tasks.AddTask.DriveTo( this._mechanicVehicle, vehiclePosition, 15f, 40, (int)DrivingStyle.Rushed );
            tasks.AddTask.RunTo( openHoodPosition );
            tasks.AddTask.TurnTo( vehicle, 1000 );
            tasks.AddTask.Wait( 1000 );
            tasks.AddTask.GoTo( shootPosition );
            tasks.AddTask.ShootAt( vehiclePosition, 15500, FiringPattern.FullAuto );
            tasks.AddTask.GoTo( openHoodPosition );
            tasks.AddTask.TurnTo( vehicle, 1000 );
            tasks.AddTask.Wait( 1000 );
            tasks.AddTask.CruiseWithVehicle( this._mechanicVehicle, 30f, (int)DrivingStyle.Rushed );
            tasks.Close();

            this._taskSequenceEventController.Subscribe( 2, this._mechanicPed, tasks,
                () =>
                {
                    this._mechanicVehicle.LeftIndicatorLightOn = true;
                    this._mechanicVehicle.RightIndicatorLightOn = true;
                } );

            this._taskSequenceEventController.Subscribe( 4, this._mechanicPed, tasks,
                () => this.OpenVehicleHood( vehicle ) );

            this._taskSequenceEventController.Subscribe( 5, this._mechanicPed, tasks,
                () =>
                {
                    vehicleEngine.Temperature -= 0.5f;
                    vehicleEngine.Damage -= 5.5f;
                    vehicle.EngineHealth += vehicle.EngineHealth >= 1000 ? 0 : 2f;
                }, true );

            this._taskSequenceEventController.Subscribe( 8, this._mechanicPed, tasks,
                () => this.OpenVehicleHood( vehicle, false ) );

            this._taskSequenceEventController.Subscribe( 9, this._mechanicPed, tasks,
                () =>
                {
                    this._mechanicPed.MarkAsNoLongerNeeded();
                    this._mechanicPed.Task.CruiseWithVehicle( this._mechanicVehicle, 30f,
                        (int)DrivingStyle.AvoidTrafficExtremely );
                    vehicle.IsDriveable = true;
                    this._mechanicBlip.Remove();
                    this._taskSequenceEventController.UnsubscribeAll( this._mechanicPed, tasks );
                    this._mechanicVehicle.MarkAsNoLongerNeeded();
                    this._mechanicVehicle.LeftIndicatorLightOn = false;
                    this._mechanicVehicle.RightIndicatorLightOn = false;
                    this._isCalled = false;
                }
                );

            this._mechanicPed.Task.PerformSequence( tasks );
            this._mechanicBlip = this._mechanicPed.AddBlip();
            this._mechanicBlip.Color = BlipColor.Blue;
            this._mechanicBlip.Name = "Mechanic";
            this._isCalled = true;
        }
Beispiel #21
0
        //destination blip
        private void add_destination_blip()
        {
            try
            {

                destination = GTA.World.CreateBlip(new Vector3(get_co("destination", 0, 'x'), get_co("destination", 0, 'y'), get_co("destination", 0, 'z')));
                destination.Color = BlipColor.Blue;

            }

            catch (Exception)
            {
                UI.ShowSubtitle("ADD_DESTINATION_ERROR");
            }
        }
Beispiel #22
0
 public BlipObject(string name, Blip blip)
     : base(blip.Handle)
 {
     Name = name;
     Blip = blip;
 }
Beispiel #23
0
        public void Clear()
        {
            /*if (_mainVehicle != null && Character.IsInVehicle(_mainVehicle) && Game.Player.Character.IsInVehicle(_mainVehicle))
            {
                _playerSeat = Util.GetPedSeat(Game.Player.Character);
            }
            else
            {
                _playerSeat = -2;
            }*/

            if (Character != null)
            {
                Character.Model.MarkAsNoLongerNeeded();
                Character.Delete();
            }
            if (_mainBlip != null)
            {
                _mainBlip.Remove();
                _mainBlip = null;
            }
            if (MainVehicle != null && Util.IsVehicleEmpty(MainVehicle))
            {
                MainVehicle.Model.MarkAsNoLongerNeeded();
                MainVehicle.Delete();
            }
            if (_parachuteProp != null)
            {
                _parachuteProp.Delete();
                _parachuteProp = null;
            }
        }
Beispiel #24
0
 public void nameBlip(Blip blip, string text)
 {
     Function.Call(GTA.Native.Hash._0xF9113A30DE5C6670, "STRING");
     Function.Call(GTA.Native.Hash._ADD_TEXT_COMPONENT_STRING, text);
     Function.Call(GTA.Native.Hash._0xBC38B49BCB83BC9B, blip);
 }
        private void OnTick(object sender, EventArgs e)
        {
            if (Game.Player.Character.IsInVehicle() || Game.Player.Character.IsSittingInVehicle()) {
                var v = Game.Player.Character.CurrentVehicle;
                if (_godEnabled) {
                    v.BodyHealth = v.MaxHealth;
                    v.EngineHealth = v.MaxHealth;
                    v.PetrolTankHealth = v.MaxHealth;
                    v.Health = v.MaxHealth;
                    GTAFuncs.SetEntityInvinc(v, true);
                }
                else GTAFuncs.SetEntityInvinc(v, false);
            }

            if (_godEnabled) Game.Player.Character.Health = Game.Player.Character.MaxHealth;

            GTAFuncs.SetInvincTime(_godEnabled ? 30000 : 0);
            GTAFuncs.SetSPInvinc(_player, _godEnabled);

            if (GTAFuncs.IsWaypointActive())
                _lastWaypoint = new Blip(GTAFuncs.GetFirstBlipInfoID((int) BlipSprite.Waypoint));

            if (_noClipEnabled) {
                Game.Player.Character.Rotation = GameplayCamera.Rotation;

                GTAFuncs.SetEntityGravity(Game.Player.Character, false);
                GTAFuncs.SetEntityLoadColissionFlag(Game.Player.Character, false);
                GTAFuncs.SetEntityRecordsCollisions(Game.Player.Character, false);
                GTAFuncs.SetEntityCollision(Game.Player.Character, false, false);
                GTAFuncs.DisableControlAction(Control.MoveUp, true);
                GTAFuncs.DisableControlAction(Control.MoveDown, true);
                GTAFuncs.DisableControlAction(Control.MoveLeft, true);
                GTAFuncs.DisableControlAction(Control.MoveRight, true);
                GTAFuncs.DisableControlAction(Control.Attack, true);
                GTAFuncs.DisableControlAction(Control.Aim, true);

                var v = new Vector3(0, 0, 0);

                if (Game.Player.Character.IsInVehicle() || Game.Player.Character.IsSittingInVehicle())
                    Game.Player.Character.Position = Game.Player.Character.Position;

                if (GTAFuncs.GetControlNormal(Control.MoveUp) != 0) {
                    v += Vector3.Multiply(Game.Player.Character.ForwardVector,
                        -25*GTAFuncs.GetControlNormal(Control.MoveUp));
                }
                if (GTAFuncs.GetControlNormal(Control.MoveRight) != 0) {
                    v += Vector3.Multiply(Game.Player.Character.RightVector,
                        25*GTAFuncs.GetControlNormal(Control.MoveRight));
                }
                if (GTAFuncs.IsControlPressed(Control.Attack)) {
                    v += Vector3.Multiply(Game.Player.Character.UpVector, 15);
                }
                if (GTAFuncs.IsControlPressed(Control.Aim)) {
                    v += Vector3.Multiply(Game.Player.Character.UpVector, -15);
                }

                Game.Player.Character.Velocity = v;
            }
            else {
                GTAFuncs.EnableControlAction(Control.MoveUp, true);
                GTAFuncs.EnableControlAction(Control.MoveDown, true);
                GTAFuncs.EnableControlAction(Control.MoveLeft, true);
                GTAFuncs.EnableControlAction(Control.MoveRight, true);
                GTAFuncs.EnableControlAction(Control.Attack, true);
                GTAFuncs.EnableControlAction(Control.Aim, true);
                GTAFuncs.SetEntityGravity(Game.Player.Character, true);
                GTAFuncs.SetEntityLoadColissionFlag(Game.Player.Character, true);
                GTAFuncs.SetEntityRecordsCollisions(Game.Player.Character, true);
                GTAFuncs.SetEntityCollision(Game.Player.Character, true, true);
            }

            if (_developerConsole.Debug && ConsoleSettings.IsDevBuild) GTAFuncs.AntiBan();
        }
Beispiel #26
0
 public void SetBlipNameFromTextFile(Blip blip, string text)
 {
     Function.Call(Hash._0xF9113A30DE5C6670, "STRING");
     Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
     Function.Call(Hash._0xBC38B49BCB83BC9B, blip);
 }
        static public void tick()
        {
            UIText Instruct = new UIText("delay: " + delay.getdelay(), new Point(400, 300), (float)0.9);
            //Instruct.Draw();

            try
            {
                if (isintruck)
                {
                    if (TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.IsInRangeOf(Docstruck.GetOffsetInWorldCoords(new Vector3(0, 0, 0)), (float)2.6))
                    {
                        Docstruck.CloseDoor(VehicleDoor.Trunk, true);
                        isintruck = false;
                        DocsExparamentstart = true;
                        delay.Reset();
                    }
                    else
                    {
                        if (!driveonce)
                        {
                            Doc.Task.DriveTo(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon, Docstruck.GetOffsetInWorldCoords(new Vector3(0, 0, 0)), 1, 10);
                            driveonce = true;
                        }
                    }
                }
            }
            catch
            {

            }

            if (DocsExparamentstart)
            {
                if (!tasksent)
                {
                    if (Game.Player.Character.IsInRangeOf(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(0, 0, 0)), (float)20.8))
                    {
                        if (!runonce)
                        {
                            loction.Remove();
                            loction = null;
                            tasksent = true;
                            runonce = true;
                            delay.Start();
                            DeloreonEnter.Play();
                        }
                    }
                    if (Game.Player.Character.IsInRangeOf(Doc.GetOffsetInWorldCoords(new Vector3(0, 0, 0)), (float)24.8))
                    {
                        Einstein.Task.RunTo(Game.Player.Character.GetOffsetInWorldCoords(new Vector3(0, 2, 0)));
                    }
                }
                else if (tasksent)
                {
                    tasksent = false;
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Repair();
                }

                if (delay.getdelay() == 24.5)
                {
                    Docstruck.OpenDoor(VehicleDoor.Trunk, false, false);
                }
                else if (delay.getdelay() >= 74)
                {
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.EngineRunning = false;
                    if (delay.getdelay() >= 68)
                    {
                        Doc.Task.LeaveVehicle(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon, false);
                        DocsExparamentstart = false;
                        runonce = false;
                        //sayshi = true;
                        delay.Stop();
                        delay.Reset();
                    }
                }
                else if (delay.getdelay() >= 38 && delay.getdelay() <= 60)
                {
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed = (float)-0.9;
                }
            }
            else if (sayshi)
            {
                if (Game.Player.Character.IsInRangeOf(Doc.GetOffsetInWorldCoords(new Vector3(0, 0, 0)), (float)3.8))
                {
                    Doc.Task.LookAt(Game.Player.Character);
                    if (!runonce)
                    {
                        Experimentstart.Play();
                        runonce = true;
                        delay.Start();
                    }
                }

                if (delay.getdelay() >= 7)
                {
                    delay.Stop();
                    delay.Reset();
                    runonce = false;
                    ExperimentwithEinstein = true;
                    sayshi = false;
                }
            }
            else if (ExperimentwithEinstein)
            {
                UI.ShowSubtitle("Experiment with Einstein is on");
                if (Game.IsKeyPressed(Keys.Up))
                {
                    Doc.Task.LookAt(Game.Player.Character);
                    if (!runonce)
                    {
                        runonce = true;
                        delay.Start();
                    }
                }

                if (delay.getdelay() == 0)
                {
                    UIText Instruct2 = new UIText("Take out phone and open the camera app", new Point(400, 300), (float)0.9);
                    Instruct2.Draw();
                }
                else if (delay.getdelay() == 5)
                {
                    Experimentstartintro.Play();
                }
                else if (delay.getdelay() < 35)
                {
                    if (delay.getdelay() == 18)
                    {
                        Einstein.Task.RunTo(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(-5, -4, 0)), true, 10);
                        Einstein.Task.RunTo(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(-3, 0, 0)), true, 10);
                    }
                    else if (delay.getdelay() == 24)
                    {
                        if (Einstein.IsInVehicle(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon))
                        {
                            delay.Resume();
                            Einstein.Task.ClearAll();
                        }
                        else
                        {
                            delay.Pause();
                            Einstein.Task.ClearAll();
                            Einstein.Task.WarpIntoVehicle(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon, VehicleSeat.Driver);
                        }
                    }
                }
                else if (delay.getdelay() >= 36)
                {
                    delay.Stop();
                    delay.Reset();
                    runonce = false;
                    //Docwithremote = true;
                    ExperimentwithEinstein = false;
                    Einstein.Task.ClearAll();
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.EngineRunning = true;
                }
            }
            else if (Docwithremote)
            {
                UI.ShowSubtitle("Remote with doc is on");
                try
                {
                    if (!pressede)
                        if (!TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].RCmode)
                        {
                            UIText Instruct2 = new UIText("Switch to Remote Control Mode in the menu. Have it set the Car " + TimeTravel.instantDelorean.Deloreanlist.Count, new Point(400, 300), (float)0.9);
                            Instruct2.Draw();
                        }
                        else if (TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].RCmode)
                        {
                            if (!runonce)
                            {
                                posblip = World.CreateBlip(Docstruck.GetOffsetInWorldCoords(new Vector3(0, -250, 0)), 5);
                                posblip.Color = BlipColor.Yellow;
                                runonce = true;
                            }
                            UIText Instruct2 = new UIText("Press E when Ready", new Point(400, 300), (float)0.9);
                            Instruct2.Draw();
                        }

                    if (Game.IsKeyPressed(Keys.E))
                    {
                        if (runonce)
                        {
                            runonce = false;
                            Experimentstartwithremote.Play();
                            delay.Start();
                        }
                    }
                    else if (delay.getdelay() >= 10 && delay.getdelay() <= 24)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed = 0;
                    }
                    else if (delay.getdelay() >= 25 && delay.getdelay() <= 62)
                    {
                        if (TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed < 46)
                        {
                            TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.PlaceOnGround();
                            TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed += (float)0.1;
                        }
                    }
                    else if (delay.getdelay() == 58)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.IsVisible = false;
                    }
                    else if (delay.getdelay() == 59)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed = 0;
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].ifwentoutoffcar = true;
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].RCmode = false;
                    }
                    else if (delay.getdelay() == 60)
                    {
                        Experimentsuccess.Play();
                    }
                    else if (delay.getdelay() == 62)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].RCmodeenabled = true;
                    }
                    else if (delay.getdelay() == 114)
                    {
                        Einstein = TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.CreatePedOnSeat(VehicleSeat.Driver, PedHash.Chop);
                        delay.Stop();
                        delay.Reset();
                        Experimentstartwithreentry.Play();
                        Docwithremote = false;
                        reentry = true;
                    }
                }
                catch (Exception e)
                {
                    UI.ShowSubtitle(e.Message + " " + e.Source);
                }

                
            }
            else if (reentry)
            {
                if (delay.getdelay() == 0)
                {
                    delay.Start();
                }
                else if (delay.getdelay() == 3)
                {
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Position = Doc.GetOffsetInWorldCoords(new Vector3(3, -18, 0));
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Rotation = Docstruck.Rotation;
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed = 30;
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.IsVisible = true;
                }
                else if (delay.getdelay() < 4 && delay.getdelay() > 26)
                {
                    if (TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed > 0)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Speed -= (float)0.1;
                    }
                    World.AddExplosion(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(-1, -2, 0)), ExplosionType.Car, 10, 0);
                }
                else if (delay.getdelay() == 26)
                {
                    World.AddExplosion(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(-1, -2, 0)), ExplosionType.Car, 14, 0);

                    World.AddExplosion(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(1, -2, 0)), ExplosionType.Car, 14, 0);

                }
                else if (delay.getdelay() < 40)
                {
                    World.AddExplosion(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3(-1, -2, 0)), ExplosionType.Car, 10, 0);
                }
                else if (delay.getdelay() == 40)
                {
                    Doc.Task.RunTo(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.GetOffsetInWorldCoords(new Vector3((float)-2.5, 0, 0)));
                }
                else if (delay.getdelay() == 51)
                {
                    Doc.Task.EnterVehicle(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon, VehicleSeat.Driver);
                }
                else if (delay.getdelay() == 52)
                {
                    Doc.Task.ClearAll();
                }
                else if (delay.getdelay() == 58)
                {
                    Einstein.Task.LeaveVehicle();
                }
                else if (delay.getdelay() == 80)
                {
                    Doc.Task.EnterVehicle(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon, VehicleSeat.Driver);
                }
                else if (delay.getdelay() >= 84 && delay.getdelay() < 124)
                {
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].toggletimecurcuits = true;

                    if (delay.getdelay() >= 98)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Settime(0, 4, 0, 7, 1, 7, 7, 6, 0, 8, 1, 2, "am");
                    }
                    if (delay.getdelay() >= 103)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Settime(2, 5, 1, 2, 0, 0, 0, 0, 1, 1, 1, 2, "am");
                    }
                    if (delay.getdelay() >= 110)
                    {
                        TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Settime(0, 5, 0, 9, 1, 9, 5, 5, 1, 1, 1, 2, "am");
                    }
                }
                else if (delay.getdelay() == 124)
                {
                    TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].toggletimecurcuits = false;
                    delay.Stop();
                    delay.Reset();
                    reentry = false;
                    Libeadsappear = true;
                    Doc.Task.LeaveVehicle(TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon, true);
                }
            }
            else if (Libeadsappear)
            {

            }
            delay.Delay_changer();
        }
        public override void StreamIn()
        {
            gameReference = World.CreatePed(model, position, RelationshipGroup.NetworkPlayer_01);

            blip = Blip.AddBlip(gameReference);
            blip.Color = color;
            blip.Display = BlipDisplay.MapOnly;
            blip.ShowOnlyWhenNear = false;
            blip.Icon = BlipIcon.Misc_Destination;
            blip.Name = networkname;

            gameReference.Heading = heading;

            var projected = (Vector2)World.WorldToScreenProject(position);
            var rand = new System.Random();

            Weapon weapon = Weapon.Rifle_M4;
            gameReference.Weapons.AssaultRifle_M4.Ammo = 999;
            gameReference.Weapons.AssaultRifle_M4.AmmoInClip = 999;
            gameReference.Weapons.Select(weapon);

            gameReference.SenseRange = 0;
            gameReference.Task.GuardCurrentPosition();
            gameReference.BlockGestures = true;
            gameReference.BlockPermanentEvents = true;
            gameReference.Task.AlwaysKeepTask = true;
            gameReference.CowerInsteadOfFleeing = true;
        }
Beispiel #29
0
        public void DisplayLocally()
        {
            const float hRange = 200f;
            var gPos = IsInVehicle ? VehiclePosition : Position;
            var inRange = Game.Player.Character.IsInRangeOf(gPos, hRange);
            
            if (inRange && !_isStreamedIn)
            {
                _isStreamedIn = true;
                if (_mainBlip != null)
                {
                    _mainBlip.Remove();
                    _mainBlip = null;
                }
            }
            else if(!inRange && _isStreamedIn)
            {
                Clear();
                _isStreamedIn = false;
            }

            if (!inRange)
            {
                if (_mainBlip == null && _blip)
                {
                    _mainBlip = World.CreateBlip(gPos);
                    _mainBlip.Color = BlipColor.White;
                    _mainBlip.Scale = 0.8f;
                    SetBlipNameFromTextFile(_mainBlip, Name == null ? "<nameless>" : Name);
                }
                if(_blip && _mainBlip != null)
                    _mainBlip.Position = gPos;
                return;
            }

            
            if (Character == null || !Character.Exists() || !Character.IsInRangeOf(gPos, hRange) || Character.Model.Hash != ModelHash || (Character.IsDead && PedHealth > 0))
            {
                if (Character != null) Character.Delete();

                Character = World.CreatePed(new Model(ModelHash), gPos, Rotation.Z);
                if (Character == null) return;

                Character.BlockPermanentEvents = true;
                Character.IsInvincible = true;
                Character.CanRagdoll = false;
                Character.RelationshipGroup = _relGroup;
                if (_blip)
                {
                    Character.AddBlip();
                    if (Character.CurrentBlip == null) return;
                    Character.CurrentBlip.Color = BlipColor.White;
                    Character.CurrentBlip.Scale = 0.8f;
                    SetBlipNameFromTextFile(Character.CurrentBlip, Name);
                }
                return;
            }

            if (!Character.IsOccluded && Character.IsInRangeOf(Game.Player.Character.Position, 20f))
            {
                var oldPos = UI.WorldToScreen(Character.Position + new Vector3(0, 0, 1.5f));
                if (oldPos.X != 0 && oldPos.Y != 0)
                {
                    var res = UIMenu.GetScreenResolutionMantainRatio();
                    var pos = new Point((int)((oldPos.X / (float)UI.WIDTH) * res.Width),
                        (int)((oldPos.Y / (float)UI.HEIGHT) * res.Height));


                    new UIResText(Name == null ? "<nameless>" : Name, pos, 0.3f, Color.WhiteSmoke, Font.ChaletLondon, UIResText.Alignment.Centered)
                    {
                        Outline = true,
                    }.Draw();
                }
            }

            if ((!_lastVehicle && IsInVehicle && VehicleHash != 0) || (_lastVehicle && IsInVehicle && (MainVehicle == null || !Character.IsInVehicle(MainVehicle) || MainVehicle.Model.Hash != VehicleHash || VehicleSeat != Util.GetPedSeat(Character))))
            {
                if (MainVehicle != null && Util.IsVehicleEmpty(MainVehicle))
                    MainVehicle.Delete();

                var vehs = World.GetAllVehicles().OrderBy(v =>
                {
                    if (v == null) return float.MaxValue;
                    return (v.Position - Character.Position).Length();
                }).ToList();


                if (vehs.Any() && vehs[0].Model.Hash == VehicleHash && vehs[0].IsInRangeOf(gPos, 3f))
                {
                    MainVehicle = vehs[0];
                    if (Game.Player.Character.IsInVehicle(MainVehicle) &&
                        VehicleSeat == Util.GetPedSeat(Game.Player.Character))
                    {
                        Game.Player.Character.Task.WarpOutOfVehicle(MainVehicle);
                        UI.Notify("~r~Car jacked!");
                    }
                }
                else
                {
                    MainVehicle = World.CreateVehicle(new Model(VehicleHash), gPos, 0);
                }

                if (MainVehicle != null)
                {
                    MainVehicle.PrimaryColor = (VehicleColor)VehiclePrimaryColor;
                    MainVehicle.SecondaryColor = (VehicleColor)VehicleSecondaryColor;
                    MainVehicle.Quaternion = VehicleRotation;
                    MainVehicle.IsInvincible = true;
                    Character.Task.WarpIntoVehicle(MainVehicle, (VehicleSeat)VehicleSeat);

                    /*if (_playerSeat != -2 && !Game.Player.Character.IsInVehicle(_mainVehicle))
                    { // TODO: Fix me.
                        Game.Player.Character.Task.WarpIntoVehicle(_mainVehicle, (VehicleSeat)_playerSeat);
                    }*/
                }

                _lastVehicle = true;
                _justEnteredVeh = true;
                _enterVehicleStarted = DateTime.Now;
                return;
            }
           
            if (_lastVehicle && _justEnteredVeh && IsInVehicle && !Character.IsInVehicle(MainVehicle) && DateTime.Now.Subtract(_enterVehicleStarted).TotalSeconds <= 4)
            {
                return;
            }
            _justEnteredVeh = false;

            if (_lastVehicle && !IsInVehicle && MainVehicle != null)
            {
                if (Character != null) Character.Task.LeaveVehicle(MainVehicle, true);
            }

            Character.Health = PedHealth;

            _switch++;
            if (IsInVehicle)
            {
                if (VehicleSeat == (int) GTA.VehicleSeat.Driver ||
                    MainVehicle.GetPedOnSeat(GTA.VehicleSeat.Driver) == null)
                {
                    MainVehicle.Health = VehicleHealth;
                    if (MainVehicle.Health <= 0)
                    {
                        MainVehicle.IsInvincible = false;
                        //_mainVehicle.Explode();
                    }
                    else
                    {
                        MainVehicle.IsInvincible = true;
                        if (MainVehicle.IsDead)
                            MainVehicle.Repair();
                    }

                    MainVehicle.PrimaryColor = (VehicleColor) VehiclePrimaryColor;
                    MainVehicle.SecondaryColor = (VehicleColor) VehicleSecondaryColor;

                    if (VehicleMods != null && _modSwitch%50 == 0 &&
                        Game.Player.Character.IsInRangeOf(VehiclePosition, 30f))
                    {
                        var id = _modSwitch/50;

                        if (VehicleMods.ContainsKey(id) && VehicleMods[id] != MainVehicle.GetMod((VehicleMod) id))
                        {
                            Function.Call(Hash.SET_VEHICLE_MOD_KIT, MainVehicle.Handle, 0);
                            MainVehicle.SetMod((VehicleMod) id, VehicleMods[id], false);
                            Function.Call(Hash.RELEASE_PRELOAD_MODS, id);
                        }
                    }
                    _modSwitch++;

                    if (_modSwitch >= 2500)
                        _modSwitch = 0;

                    if (IsHornPressed && !_lastHorn)
                    {
                        _lastHorn = true;
                        MainVehicle.SoundHorn(99999);
                    }

                    if (!IsHornPressed && _lastHorn)
                    {
                        _lastHorn = false;
                        MainVehicle.SoundHorn(1);
                    }

                    if (MainVehicle.SirenActive && !Siren)
                        MainVehicle.SirenActive = Siren;
                    else if (!MainVehicle.SirenActive && Siren)
                        MainVehicle.SirenActive = Siren;

                    var dir = VehiclePosition - _lastVehiclePos;

                    dir.Normalize();

                    var range = Math.Max(20f, Speed*Math.Ceiling(DateTime.Now.Subtract(LastUpdateReceived).TotalSeconds));

                    if (MainVehicle.IsInRangeOf(VehiclePosition, (float) range))
                    {
                        var timeElapsed = (float) DateTime.Now.Subtract(LastUpdateReceived).TotalSeconds;
                        var acceleration = Speed - _lastSpeed;
                        MainVehicle.Position = _lastVehiclePos + dir*(Speed*timeElapsed) +
                                               dir*(0.5f*acceleration*(float) Math.Pow(timeElapsed, 2));
                    }
                    else
                    {
                        MainVehicle.Position = VehiclePosition;
                        _lastVehiclePos = VehiclePosition - (dir*0.5f);
                    }
                    #if DEBUG
                    if (MainVehicle.Heading < 270)
                        MainVehicle.Quaternion = Util.LerpQuaternion(MainVehicle.Quaternion, VehicleRotation, 0.1f);
                    else if (MainVehicle.Heading >= 270)
                        MainVehicle.Quaternion = Util.LerpQuaternion(VehicleRotation, MainVehicle.Quaternion, 0.1f);
                    #else
                    MainVehicle.Quaternion = VehicleRotation;
                    #endif
                }
            }
                else
                {
                    if (PedProps != null && _clothSwitch%50 == 0 && Game.Player.Character.IsInRangeOf(Position, 30f))
                    {
                        var id = _clothSwitch/50;

                        if (PedProps.ContainsKey(id) &&
                            PedProps[id] != Function.Call<int>(Hash.GET_PED_DRAWABLE_VARIATION, Character.Handle, id))
                        {
                            Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Character.Handle, id, PedProps[id], 0, 0);
                        }
                    }

                    _clothSwitch++;
                    if (_clothSwitch >= 750)
                        _clothSwitch = 0;

                    if (Character.Weapons.Current.Hash != (WeaponHash) CurrentWeapon)
                    {
                        var wep = Character.Weapons.Give((WeaponHash) CurrentWeapon, 9999, true, true);
                        Character.Weapons.Select(wep);
                    }

                    if (!_lastJumping && IsJumping)
                    {
                        Character.Task.Jump();
                    }

                    if (IsParachuteOpen)
                    {
                        if (_parachuteProp == null)
                        {
                            _parachuteProp = World.CreateProp(new Model(1740193300), Character.Position,
                                Character.Rotation, false, false);
                            _parachuteProp.FreezePosition = true;
                            Function.Call(Hash.SET_ENTITY_COLLISION, _parachuteProp.Handle, false, 0);
                        }
                        Character.FreezePosition = true;
                        Character.Position = Position - new Vector3(0, 0, 1);
                        Character.Quaternion = Rotation;
                        _parachuteProp.Position = Character.Position + new Vector3(0, 0, 3.7f);
                        _parachuteProp.Quaternion = Character.Quaternion;

                        Character.Task.PlayAnimation("skydive@parachute@first_person", "chute_idle_right", 8f, 5000,
                            false, 8f);
                    }
                    else
                    {
                        var dest = Position;
                        Character.FreezePosition = false;

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

                        const int threshold = 50;
                        if (IsAiming && !IsShooting && !Character.IsInRangeOf(Position, 0.5f) && _switch%threshold == 0)
                        {
                            Function.Call(Hash.TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD, Character.Handle, dest.X, dest.Y,
                                dest.Z, AimCoords.X, AimCoords.Y, AimCoords.Z, 2f, 0, 0x3F000000, 0x40800000, 1, 512, 0,
                                (uint) FiringPattern.FullAuto);
                        }
                        else if (IsAiming && !IsShooting && Character.IsInRangeOf(Position, 0.5f))
                        {
                            Character.Task.AimAt(AimCoords, 100);
                        }

                        if (!Character.IsInRangeOf(Position, 0.5f) &&
                            ((IsShooting && !_lastShooting) ||
                             (IsShooting && _lastShooting && _switch%(threshold*2) == 0)))
                        {
                            Function.Call(Hash.TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD, Character.Handle, dest.X, dest.Y,
                                dest.Z, AimCoords.X, AimCoords.Y, AimCoords.Z, 2f, 1, 0x3F000000, 0x40800000, 1, 0, 0,
                                (uint) FiringPattern.FullAuto);
                        }
                        else if ((IsShooting && !_lastShooting) ||
                                 (IsShooting && _lastShooting && _switch%(threshold/2) == 0))
                        {
                            Function.Call(Hash.TASK_SHOOT_AT_COORD, Character.Handle, AimCoords.X, AimCoords.Y,
                                AimCoords.Z, 1500, (uint) FiringPattern.FullAuto);
                        }

                        if (!IsAiming && !IsShooting && !IsJumping)
                        {
                            switch (SyncMode)
                            {
                                case SynchronizationMode.Tasks:
                                    if (!Character.IsInRangeOf(Position, 0.5f))
                                    {
                                        Character.Task.RunTo(Position, true, 500);
                                        //var targetAngle = Rotation.Z/Math.Sqrt(1 - Rotation.W*Rotation.W);
                                        //Function.Call(Hash.TASK_GO_STRAIGHT_TO_COORD, Character.Handle, Position.X, Position.Y, Position.Z, 5f, 3000, targetAngle, 0);
                                    }
                                    if (!Character.IsInRangeOf(Position, 5f))
                                    {
                                        Character.Position = dest - new Vector3(0, 0, 1f);
                                        Character.Quaternion = Rotation;
                                    }
                                    break;
                                case SynchronizationMode.Teleport:
                                    Character.Position = dest - new Vector3(0, 0, 1f);
                                    Character.Quaternion = Rotation;
                                    break;
                            }
                        }
                    }
                    _lastJumping = IsJumping;
                    _lastShooting = IsShooting;
                    _lastAiming = IsAiming;
                }
                _lastVehicle = IsInVehicle;
        }
Beispiel #30
0
        /// <summary>
        /// Called when the callout has been accepted. Call base to set state to Running.
        /// </summary>
        /// <returns>
        /// True if callout was setup properly, false if it failed. Calls <see cref="End"/> when failed.
        /// </returns>
        public override bool OnCalloutAccepted()
        {
            base.OnCalloutAccepted();

            this.pursuit = Functions.CreatePursuit();
            Functions.SetPursuitCopsCanJoin(this.pursuit, false);
            Functions.SetPursuitDontEnableCopBlips(this.pursuit, true);

            // Add blip
            this.blip = Functions.CreateBlipForArea(this.spawnPoint.Position, 30f);
            this.blip.Display = BlipDisplay.ArrowAndMap;
            this.blip.RouteActive = true;

            // Decide whether prank call or not
            if (Common.GetRandomBool(0, 5, 1))
            {
                Log.Debug("OnCalloutAccepted: Is prank", this);
                this.SetAsPrankCall();
            }
            else
            {
                this.criminals = new List<LPed>();

                int random = Common.GetRandomValue(2, 10);
                for (int i = 0; i < random; i++)
                {
                    LPed criminal = new LPed(this.spawnPoint.Position, Common.GetRandomCollectionValue<string>(this.criminalModels), LPed.EPedGroup.Criminal);
                    if (criminal.Exists())
                    {
                        // Ensure ped is not in a building
                        if (criminal.EnsurePedIsNotInBuilding(criminal.Position))
                        {
                            Functions.AddToScriptDeletionList(criminal, this);
                            Functions.SetPedIsOwnedByScript(criminal, this, true);
                            criminal.RelationshipGroup = RelationshipGroup.Special;
                            criminal.ChangeRelationship(RelationshipGroup.Special, Relationship.Companion);
                            criminal.ChangeRelationship(RelationshipGroup.Gang_Albanian, Relationship.Hate);

                            // We don't want the criminal to flee yet
                            criminal.DisablePursuitAI = true;
                            criminal.EquipWeapon();

                            Functions.AddPedToPursuit(this.pursuit, criminal);
                            this.criminals.Add(criminal);
                        }
                        else
                        {
                            Log.Debug("OnCalloutAccepted: Failed to place ped properly outside of building", this);
                            criminal.Delete();
                        }
                    }
                }

                if (this.criminals.Count == 0)
                {
                    return false;
                }

                // Chance to spawn another bunch of suspects fighting each other
                if (Common.GetRandomBool(0, 2, 1))
                {
                    random = Common.GetRandomValue(2, 10);
                    for (int i = 0; i < random; i++)
                    {
                        LPed criminal = new LPed(this.spawnPoint.Position, Common.GetRandomCollectionValue<string>(this.criminalModels), LPed.EPedGroup.Criminal);
                        if (criminal.Exists())
                        {
                            Functions.AddToScriptDeletionList(criminal, this);
                            Functions.SetPedIsOwnedByScript(criminal, this, true);
                            criminal.RelationshipGroup = RelationshipGroup.Gang_Albanian;
                            criminal.ChangeRelationship(RelationshipGroup.Gang_Albanian, Relationship.Companion);
                            criminal.ChangeRelationship(RelationshipGroup.Special, Relationship.Hate);

                            // We don't want the criminal to flee yet
                            criminal.DisablePursuitAI = true;
                            criminal.EquipWeapon();

                            Functions.AddPedToPursuit(this.pursuit, criminal);
                            this.criminals.Add(criminal);
                        }
                    }

                    // Chance to start fighting immediately
                    if (Common.GetRandomBool(0, 2, 1))
                    {
                        this.State = EShootoutState.Fighting;
                        this.Engage();

                        // Request one backup unit automatically
                        Functions.RequestPoliceBackupAtPosition(LPlayer.LocalPlayer.Ped.Position);
                    }
                }
            }

            // Add states
            this.RegisterStateCallback(EShootoutState.WaitingForPlayer, this.WaitingForPlayer);
            this.RegisterStateCallback(EShootoutState.PlayerIsClose, this.PlayerIsClose);
            this.RegisterStateCallback(EShootoutState.InCombat, this.InCombat);
            this.RegisterStateCallback(EShootoutState.Fighting, this.InCombat);
            this.RegisterStateCallback(EShootoutState.Prank, this.Prank);
            this.State = EShootoutState.WaitingForPlayer;
            Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_GET_TO_CRIME_SCENE"), 8000);

            return true;
        }
Beispiel #31
0
        public static void Work()
        {
            if (IsWorking == false)
            {

                currentMoney = Game.Player.Money;
                Script.Wait(30);
                IsWorking = true;
                CustomPlayer.isWorking = true;
                GTA.Game.FadeScreenOut(1000);
                Script.Wait(1000);
                taxi1 = World.CreateVehicle(GTA.Native.VehicleHash.Taxi, new Vector3(-548f, 301f, 83f), 275f);
                Script.Wait(100);
                hours = Function.Call<int>(Hash.GET_CLOCK_HOURS);
                Script.Wait(30);
                Player.Character.SetIntoVehicle(taxi1, VehicleSeat.Driver);
                Script.Wait(1000);
                GTA.Game.FadeScreenIn(2000);
                Script.Wait(0);
                taxiblip = taxi1.AddBlip();
                taxiblip.Sprite = BlipSprite.PersonalVehicleCar;
                taxiblip.Color = BlipColor.Yellow;
                CustomPlayer.sendMessage("Press " + Style.YELLOW + "[E]" + Style.NORMAL +" to start Taxi Missions, Return back to quit working!");
            }
            else
            {
                Quit();
            }
        }
Beispiel #32
0
 /// <summary>
 /// Checks if the specific object still exists in the world
 /// </summary>
 /// <param name="ped">GTA Blip</param>
 /// <returns>True if exist, otherwise false</returns>
 internal static bool isObjectValid(this GTA.Blip blip)
 {
     return(blip != null && blip.Exists());
 }