Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CBomb"/> class.
        /// </summary>
        /// <param name="position">The spawn position.</param>
        /// <param name="model">The model.</param>
        /// <param name="bombType">The bomb type.</param>
        /// <param name="explosionType">The explosion type.</param>
        /// <param name="tickInterval">The tick interval.</param>
        public CBomb(Vector3 position, Model model, EBombType bombType, EExplosionType explosionType, int tickInterval)
        {
            this.model = model;
            this.bombType = bombType;

            this.obj = World.CreateObject(model, position);
            this.timer = new GTA.Timer(tickInterval, true);
            this.timer.Tick += new EventHandler(this.timer_Tick);

            this.creationTime = System.DateTime.Now.Ticks;
            this.state = EBombState.Armed;
            this.exType = explosionType;

            // We wait until the object has been created
            while (this.obj == null)
            {
            }

            GTA.Native.Function.Call("SET_OBJECT_AS_STEALABLE", this.obj, 1);
            //START_PTFX_ON_OBJ("ambient_cig_smoke", c.a, 0.125, -0.02, 0.01, 0.0, 0.0, 0.0, 1.1) --+z-y+x
            //ptfxHandle = GTA.Native.Function.Call<int>("START_PTFX_ON_OBJ", "shot_directed_flame", this.obj, 0, 0, 0.3, 45.0, -90.0, 45.0, 0.0);
            //
            // START_PTFX_ON_OBJ(string ptfxName, int objId, float xOffset, float yOffset, float zOffset, float yaw, float pitch, float roll, float scale)
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CRocket"/> class.
        /// </summary>
        /// <param name="startPos">The start position.</param>
        /// <param name="startDirection">The start direction.</param>
        /// <param name="bombType">Type of payload.</param>
        /// <param name="exType">Type of explosion.</param>
        /// <param name="bombTickInterval">The bomb tick interval.</param>
        /// <param name="rocketTickInterval">The rocket tick interval.</param>
        public CRocket(Vector3 startPos, Vector3 startDirection, EBombType bombType, EExplosionType exType, int bombTickInterval, int rocketTickInterval)
        {
            this.bomb = new CBomb(
                                  startPos,
                                  "cj_rpg_rocket",
                                  EBombType.payload,
                                  exType,
                                  bombTickInterval);

            this.timer = new GTA.Timer();
            this.timer.Interval = rocketTickInterval;
            this.timer.Start();
            this.timer.Tick += new EventHandler(this.timer_Tick);

            this.vel = GParams.RocketVel;

            // Example...
            //START_PTFX_ON_OBJ("ambient_cig_smoke", c.a, 0.125, -0.02, 0.01, 0.0, 0.0, 0.0, 1.1) --+z-y+x
            this.ptfxHandle = GTA.Native.Function.Call<int>("START_PTFX_ON_OBJ", "weap_rocket_player", this.bomb.Obj, 0.125, -0.02, 0.01, 0.0, 0.0, 0.0, 1.1);

            this.light = new GTA.Light(System.Drawing.Color.Orange, 15.0f, 80f);
            this.light.Position = this.bomb.Obj.GetOffsetPosition(new Vector3(0f, -2f, 0f));
            this.light.Enabled = true;
        }
Example #3
0
        public CGrenade(Vector3 startPos, Vector3 startDirection, EBombType bombType, EExplosionType exType, int bombTickInterval, int grenadeTickInterval)
        {
            this.startDir = startDirection;

            this.bomb = new CBomb(
                                  startPos,
                                  "CJ_PROP_GRENADE",
                                  EBombType.payload,
                                  exType,
                                  bombTickInterval);

            this.timer = new GTA.Timer();
            this.timer.Interval = grenadeTickInterval;
            this.timer.Start();
            this.timer.Tick += new EventHandler(timer_Tick);

            this.bomb.Obj.Collision = true;
            this.bomb.Obj.SetRecordCollisions(true);

            this.ptfxHandle = GTA.Native.Function.Call<int>("START_PTFX_ON_OBJ", "weap_molotov_smoke", this.bomb.Obj, 0.125, -0.02, 0.01, 0.0, 0.0, 0.0, 1.1);

            this.bomb.Obj.FreezePosition = false;
            this.bomb.Obj.Rotation = GTA.Helper.DirectionToRotation(startDirection, 0f);
        }
Example #4
0
        /// <summary>
        /// Handles the KeyDown event of the BombScript control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GTA.KeyEventArgs"/> instance containing the event data.</param>
        private void BombScript_KeyDown(object sender, GTA.KeyEventArgs e)
        {
            if (e.Key == GParams.ProjectileChangeKey)
            {
                switch (this.projType)
                {
                    case EProjectileType.Rocket:
                        this.projType = EProjectileType.Grenade;
                        break;

                    case EProjectileType.Grenade:
                        this.projType = EProjectileType.Rocket;

                        break;
                }

                Game.DisplayText("Projectile type: " + this.projType.ToString(), 1800);
            }
            else if (e.Key == GParams.RocketStartKey)
            {
                if (Game.isGameKeyPressed(GameKey.Aim) && !Player.Character.isInVehicle())
                {
                    switch (this.projType)
                    {
                        case EProjectileType.Rocket:
                            if (!this.rocketActive)
                            {
                                this.rocket = new CRocket(Game.CurrentCamera.Position + Game.CurrentCamera.Direction * 3.0f, Game.CurrentCamera.Direction, this.currentBombType, this.currentExplosionType, 5, 0);
                                this.rocketActive = true;
                            }

                            break;

                        case EProjectileType.Grenade:
                            CGrenade tempGrenade = new CGrenade(Game.CurrentCamera.Position + 1.0f * Game.CurrentCamera.Direction, Game.CurrentCamera.Direction, this.currentBombType, this.currentExplosionType, 5, 0);

                            break;
                    }
                }
            }
            else if (e.Key == GParams.BombPlaceKey)
            {
                Vector3 pos = Player.Character.Position;

                lock (this.bombs)
                {
                    // Too many bombs: start over
                    if (this.bombCounter > GParams.MaxBombs)
                    {
                        this.bombCounter = 0;

                        if (this.bombs[0] != null)
                        {
                            this.bombs[0].Delete();
                            this.bombs.RemoveAt(0);
                        }
                    }

                    this.bombs.Add(new CBomb(
                                             Player.Character.GetOffsetPosition(new Vector3(0f, 1f, 0f)).ToGround(),
                                             "EC_BOMB_NE",
                                             this.currentBombType,
                                             this.currentExplosionType,
                                             5));
                    this.bombCounter++;
                }
            }
            else if (e.Key == GParams.BombDetonateKey)
            {
                if (this.detMethod == EDetonationMethod.Parallel)
                {
                    GVars.DetonateTime = System.DateTime.Now.Ticks;
                }
                else if (this.detMethod == EDetonationMethod.Serial)
                {
                    for (int i = 0; i < this.bombs.Count; i++)
                    {
                        if (this.bombs[i].Type == EBombType.manual)
                        {
                            this.bombs[i].Explode();
                            Wait(20);
                            this.bombs[i].Delete();
                            Wait(10);
                        }
                    }
                }
            }
            else if (e.Key == GParams.BombChangeTypeKey)
            {
                if ((int)this.currentBombType + 1 < GParams.NumBombTypes)
                {
                    this.currentBombType++;
                }
                else
                {
                    this.currentBombType = 0;
                }

                Game.DisplayText("Bomb type: " + this.currentBombType.ToString(), 1800);
            }
            else if (e.Key == GParams.DetTypeChangeKey)
            {
                if ((int)this.detMethod + 1 < GParams.NumDetTypes)
                {
                    this.detMethod++;
                }
                else
                {
                    this.detMethod = 0;
                }

                Game.DisplayText("Det method: " + this.detMethod.ToString(), 1800);
            }
            else if (e.Key == GParams.ExTypeChangeKey)
            {
                if ((int)this.currentExplosionType + 1 < GParams.NumExTypes)
                {
                    this.currentExplosionType++;
                }
                else
                {
                    this.currentExplosionType = 0;
                }

                Game.DisplayText("Explosion type: " + this.currentExplosionType.ToString(), 1800);
            }
        }