Exemple #1
0
        private void StartStarman()
        {
            string chosenTheme = starmanThemes[rnd.Next(1, starmanThemes.Length)];

            while (chosenTheme == previousTheme)
            {
                chosenTheme = starmanThemes[rnd.Next(1, starmanThemes.Length)];
            }
            previousTheme = chosenTheme;

            // get the settings when Starman is activated
            ScriptSettings tss = ScriptSettings.Load(@"scripts\Starman.ini");

            volume = float.Parse(tss.GetValue("Settings", "Volume", "0.4"));
            tss    = null;

            audioReader        = new AudioFileReader("scripts/starman/" + chosenTheme + ".mp3");
            audioReader.Volume = volume;
            DelayFadeOutSampleProvider fadeOut = new DelayFadeOutSampleProvider(audioReader);

            fadeOut.BeginFadeOut((starmanTime * 1000) - (fadeOutTime * 1000), fadeOutTime * 1000);
            waveOut = new WaveOutEvent();
            waveOut.PlaybackStopped += waveOut_PlaybackStopped;
            waveOut.Init(fadeOut);
            waveOut.Play();

            btb                 = new BarTimerBar("STARMAN POWER");
            btb.Percentage      = 1;
            btb.ForegroundColor = ExtendedColor.HSL2RGB(0, 1, 0.5);
            btb.BackgroundColor = ExtendedColor.HSL2RGB(0, 1, 0.3);
            tbPool.Add(btb);

            activated = true;
            SetInvulnerability(activated);
        }
Exemple #2
0
        private void onTick(object sender, EventArgs e)
        {
            if (activated && !hasReloaded)
            {
                // how long has starman been activated?
                if (dateTimeThatStarmanWasInitiated != janFirst1970)
                {
                    elapsedTime = DateTime.Now - dateTimeThatStarmanWasInitiated;
                }

                // update the progress bar
                if (btb != null && elapsedTime.TotalSeconds <= starmanTime)
                {
                    btb.Percentage = 1 - ((float)elapsedTime.TotalSeconds / starmanTime);
                    float hue = ((float)elapsedTime.TotalSeconds / starmanTime);
                    btb.ForegroundColor = ExtendedColor.HSL2RGB(hue, 1, 0.5);
                    btb.BackgroundColor = ExtendedColor.HSL2RGB(hue, 1, 0.3);
                }

                tbPool.Draw();

                if (elapsedTime.TotalSeconds > starmanTime)  // starman finished
                {
                    EndStarman();
                }
                else if (elapsedTime.TotalSeconds <= starmanTime)    // starman is still running
                // particles execute every 0.5 seconds
                {
                    if (Math.Round(elapsedTime.TotalSeconds, 2) % 0.5d == 0)
                    {
                        if (player.Character.IsInVehicle())
                        {
                            ParticleOnEntity(player.Character.CurrentVehicle, "scr_rcbarry1", "scr_alien_teleport", 1.0f);
                        }
                        else
                        {
                            ParticleOnEntity(player.Character, "scr_rcbarry1", "scr_alien_teleport", 1.0f);
                        }
                    }

                    // is the player in a vehicle?
                    if (player.Character.IsInVehicle())
                    {
                        // infinite health
                        Vehicle vehicle = player.Character.CurrentVehicle;
                        vehicle.CanBeVisiblyDamaged = false;
                        vehicle.CanTiresBurst       = false;
                        vehicle.CanWheelsBreak      = false;
                        vehicle.EngineCanDegrade    = false;
                        vehicle.IsBulletProof       = true;
                        vehicle.IsExplosionProof    = true;
                        vehicle.IsFireProof         = true;

                        // explode on contact
                        Vehicle[] vehicles = World.GetNearbyVehicles(vehicle.Position, destructionRadius);
                        if (vehicles.Length > 0)
                        {
                            foreach (Vehicle v in vehicles)
                            {
                                if (v != player.Character.CurrentVehicle)
                                {
                                    if (player.Character.CurrentVehicle.IsTouching(v))
                                    {
                                        v.Explode();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        // super jump
                        if (bool.Parse(ss.GetValue("Settings", "JumpBoost")))
                        {
                            player.SetSuperJumpThisFrame();
                        }

                        // kill closeby peds
                        Ped[] peds = World.GetNearbyPeds(player.Character.Position, destructionRadius - 4.5f);
                        if (peds.Length > 0)
                        {
                            foreach (Ped p in peds)
                            {
                                if (p != player.Character)
                                {
                                    p.Kill();
                                }
                            }
                        }
                    }
                }
            }
            // if the mod has been reloaded
            if (hasReloaded && activated)
            {
                Wait(3000);
                hasReloaded = false;
                UI.Notify("The cooldown for the Starman mod is over.");
                EndStarman();
            }
        }