예제 #1
0
            /// <summary>
            /// Remove the script fire.
            /// </summary>
            public void Remove()
            {
                if (removed)
                {
                    return;
                }

                WorldExtension.RemoveScriptFire(this.handle);
                removed = true;
            }
예제 #2
0
            /// <summary>
            /// Move the script fire to the pedestrian.
            /// </summary>
            public void MoveToPed()
            {
                if (removed)
                {
                    return;
                }

                if (ped.IsOnFire || !ped.IsAlive)
                {
                    this.Remove();
                    return;
                }

                WorldExtension.RemoveScriptFire(this.handle);
                this.handle = WorldExtension.StartScriptFire(ped.Position, 5, true);
            }
예제 #3
0
        public void Handle(Chaos mod, String from, IEnumerable <String> rest)
        {
            Ped player = Game.Player.Character;

            if (player == null)
            {
                mod.ShowText($"{from} tried to put EVERYONE on fire!");
                return;
            }

            var peds = World.GetNearbyPeds(player.Position, 1000f);

            var scriptFires = new List <ScriptFire>();

            foreach (var ped in peds)
            {
                if (ped.IsHuman && !ped.IsOnFire && ped.IsAlive && ped != player)
                {
                    if (ped.CurrentVehicle != null)
                    {
                        ped.Task.ClearAll();
                        ped.AlwaysKeepTask = true;
                        ped.Task.LeaveVehicle();
                    }

                    ped.Euphoria.OnFire.Start(10_000);
                    var id = WorldExtension.StartScriptFire(ped.Position, 5, true);
                    scriptFires.Add(new ScriptFire(id, ped));
                }
            }

            if (scriptFires.Count == 0)
            {
                mod.ShowText($"{from} tried to put pedestrians on fire but there are none :(");
                return;
            }

            var timer = mod.Timer("Peds On Fire", 10f);

            mod.AddTicker(new SetPedsOnFireTicker(scriptFires, timer));
            mod.ShowText($"{from} set {scriptFires.Count} pedestrians on fire!");
        }
예제 #4
0
파일: Drunk.cs 프로젝트: udoprog/ChaosMod
        public void Handle(Chaos mod, String from, IEnumerable <String> rest)
        {
            var player = Game.Player.Character;

            if (player == null)
            {
                return;
            }

            float  amplitude    = 1f;
            string animationSet = "move_m@drunk@moderatedrunk";
            string what         = "drunk";

            if (veryDrunk)
            {
                amplitude    = 5f;
                animationSet = "move_m@drunk@verydrunk";
                what         = "VERY drunk";
                Function.Call(Hash._START_SCREEN_EFFECT, "DrugsDrivingOut", 0, 0);
            }

            var timer        = mod.Timer(what, 20f);
            var stumbleTimer = mod.RandomTimer(2f, 5f);

            if (!WorldExtension.HasAnimationSetLoaded(animationSet))
            {
                WorldExtension.RequestAnimationSet(animationSet);
            }

            GameplayCamera.Shake(CameraShake.Drunk, amplitude);
            player.SetPedIsDrunk(true);
            player.SetConfigFlag(100, true);
            player.SetPedMovementClipset(animationSet);
            mod.AddUniqueTicker(TickerId.Drunk, new DrunkTicker(mod.Rnd, timer, stumbleTimer, player));
            mod.ShowText($"{from} made you {what}!");
        }
예제 #5
0
    private void Update()
    {
        if (inputActive && Input.GetMouseButtonUp(0))
        {
            StartLocation     = transform.position.ToVector3_2D();
            timer             = 0;
            TargetLocation    = WorldExtension.GetScreenPositionFor2D(Input.mousePosition);
            startedTravelling = true;
            //Work out if a battle is going to happen and if it's likely
            //then set the distance the player will travel before it happens
            // Выясняем произойдет ли сражение и если это возможно, устанавливаем расстояие пройденное игроком до того, как оно произойдет.
            int EncounterProbability = Random.Range(1, 100);
            if (EncounterProbability < EncounterChance && !GameState.PlayerReturningHome) // тут происходит проверка шанса боя. Интересный код))!!
            {
                EncounterDistance = (Vector3.Distance(StartLocation, TargetLocation) / 100) * Random.Range(10, 100);
            }
            else
            {
                EncounterDistance = 0.0f;
            }
        }

        /* // Input touch для тача
         * else if (inputActive && Input.touchCount == 1)
         * {
         *  StartLocation = transform.position.ToVector3_2D();
         *  timer = 0;
         *  TargetLocation = WorldExtensions.GetScreenPositionFor2D(Input.GetTouch(0).position);
         *  startedTravelling = true;
         *  var EncounterProbability = Random.Range(1, 100);
         *  if (EncounterProbability < EncounterChance && !GameState.playerReturningHome)
         *  {
         *      EncounterDistance = (Vector3.Distance(StartLocation, TargetLocation) / 100) * Random.Range(10, 100);
         *  }
         *  else
         *  {
         *      EncounterDistance = 0;
         *  }
         * }
         */
        if (TargetLocation != Vector3.zero && TargetLocation != transform.position && TargetLocation != StartLocation)
        {
            float dist = Vector3.Distance(StartLocation, TargetLocation);
            transform.position = Vector3.Lerp(StartLocation, TargetLocation, timer / dist);//movementCureve.Evaluate(timer)// регулировка спомощью AnimationCurve
            timer += Time.fixedDeltaTime;
        }
        if (startedTravelling && Vector3.Distance(StartLocation, transform.position.ToVector3_2D()) > 0.5)
        {
            this.GetComponent <Collider2D>().enabled = true;
            startedTravelling = false;
        }
        //If there is an encounter distance, then a battle must occur.
        //So when the player has travelled far enough, stop and enter the battle scene
        if (EncounterDistance > 0)
        {
            if (Vector3.Distance(StartLocation, transform.position) > EncounterDistance)
            {
                TargetLocation = Vector3.zero;
                NavigationManager.NavigateTo("Battle");
            }
        }
        if (!inputReady && inputActive)
        {
            TargetLocation = this.transform.position;
        }
        inputActive = inputReady;
    }