Example #1
0
        /// <summary>
        /// Add Passenger
        /// </summary>
        public void Enter(Unit passenger)
        {
            this._passenger = passenger;

            passenger.m_vehicleSeat        = this;
            passenger.MovementFlags       |= MovementFlags.OnTransport;
            passenger.TransportPosition    = Entry.AttachmentOffset;
            passenger.TransportOrientation = Entry.PassengerYaw;
            Vehicle._passengerCount++;

            if (IsDriverSeat)
            {
                Vehicle.Charmer    = passenger;
                passenger.Charm    = Vehicle;
                Vehicle.UnitFlags |= UnitFlags.Possessed;
            }

            var chr = passenger as Character;
            var pos = Vehicle.Position;

            // this will be null if its not a character
            if (chr != null)
            {
                VehicleHandler.Send_SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA(chr);
                VehicleHandler.SendBreakTarget(chr, Vehicle);
            }

            MovementHandler.SendEnterTransport(passenger);

            if (chr != null)
            {
                MiscHandler.SendCancelAutoRepeat(chr, Vehicle);
                //var orientation = Vehicle.m_vehicleSeat != null ? Vehicle.m_vehicleSeat.Entry.PassengerYaw : 0;
                //var moveflags = Vehicle.m_vehicleSeat != null ? MonsterMoveFlags.Flag_0x1000000 : MonsterMoveFlags.Walk;
                //MovementHandler.SendMoveToPacket(Vehicle, ref pos, orientation, 0, moveflags);
                PetHandler.SendVehicleSpells(chr, Vehicle);
            }

            passenger.IncMechanicCount(SpellMechanic.Rooted, true);
            passenger.HasPermissionToMove = false;
            passenger.MovementFlags      |= MovementFlags.Root;

            if (chr != null)
            {
                chr.SetMover(Vehicle, IsDriverSeat);
                chr.FarSight = Vehicle.EntityId;
            }
        }
Example #2
0
        /// <summary>
        /// Remove Passenger
        /// </summary>
        public void ClearSeat()
        {
            if (_passenger == null)
            {
                return;
            }

            if (IsDriverSeat)
            {
                Vehicle.Charmer    = null;
                _passenger.Charm   = null;
                Vehicle.UnitFlags &= ~UnitFlags.Possessed;
            }

            Vehicle._passengerCount--;
            if (_passenger.MovementFlags.HasFlag(MovementFlags.Flying))
            {
                var cast = Vehicle.SpellCast;
                if (cast != null)
                {
                    cast.Trigger(SpellId.EffectParachute);
                }
            }

            _passenger.MovementFlags &= ~MovementFlags.OnTransport;
            _passenger.Auras.RemoveFirstVisibleAura(aura => aura.Spell.IsVehicle);

            if (_passenger is Character)
            {
                var chr = (Character)_passenger;
                VehicleHandler.Send_SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA(chr);
                //SendTeleportAck
                MovementHandler.SendMoved(chr);
                MiscHandler.SendCancelAutoRepeat(chr, Vehicle);
                PetHandler.SendEmptySpells(chr);
                chr.ResetMover();
                chr.FarSight = EntityId.Zero;

                //MovementHandler.SendEnterTransport(chr);
            }
            _passenger.m_vehicleSeat = null;
            MovementHandler.SendHeartbeat(_passenger, _passenger.Position, _passenger.Orientation);
            _passenger.DecMechanicCount(SpellMechanic.Rooted, true);
            _passenger.HasPermissionToMove = true;
            _passenger.MovementFlags      &= ~MovementFlags.Root;
            _passenger = null;
        }
Example #3
0
        /// <summary>Add Passenger</summary>
        public void Enter(Unit passenger)
        {
            this._passenger                = passenger;
            passenger.m_vehicleSeat        = this;
            passenger.MovementFlags       |= MovementFlags.OnTransport;
            passenger.TransportPosition    = this.Entry.AttachmentOffset;
            passenger.TransportOrientation = this.Entry.PassengerYaw;
            ++this.Vehicle._passengerCount;
            if (this.IsDriverSeat)
            {
                this.Vehicle.Charmer    = passenger;
                passenger.Charm         = (Unit)this.Vehicle;
                this.Vehicle.UnitFlags |= UnitFlags.Possessed;
            }

            Character chr      = passenger as Character;
            Vector3   position = this.Vehicle.Position;

            if (chr != null)
            {
                VehicleHandler.Send_SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA(chr);
                VehicleHandler.SendBreakTarget((IPacketReceiver)chr, (IEntity)this.Vehicle);
            }

            MovementHandler.SendEnterTransport(passenger);
            if (chr != null)
            {
                MiscHandler.SendCancelAutoRepeat((IPacketReceiver)chr, (IEntity)this.Vehicle);
                PetHandler.SendVehicleSpells((IPacketReceiver)chr, (NPC)this.Vehicle);
            }

            passenger.IncMechanicCount(SpellMechanic.Rooted, true);
            passenger.HasPermissionToMove = false;
            passenger.MovementFlags      |= MovementFlags.Root;
            if (chr == null)
            {
                return;
            }
            chr.SetMover((WorldObject)this.Vehicle, this.IsDriverSeat);
            chr.FarSight = this.Vehicle.EntityId;
        }
Example #4
0
        /// <summary>Remove Passenger</summary>
        public void ClearSeat()
        {
            if (this._passenger == null)
            {
                return;
            }
            if (this.IsDriverSeat)
            {
                this.Vehicle.Charmer    = (Unit)null;
                this._passenger.Charm   = (Unit)null;
                this.Vehicle.UnitFlags &= UnitFlags.CanPerformAction_Mask1 | UnitFlags.Flag_0_0x1 |
                                          UnitFlags.SelectableNotAttackable | UnitFlags.Influenced |
                                          UnitFlags.PlayerControlled | UnitFlags.Flag_0x10 | UnitFlags.Preparation |
                                          UnitFlags.PlusMob | UnitFlags.SelectableNotAttackable_2 |
                                          UnitFlags.NotAttackable | UnitFlags.Passive | UnitFlags.Looting |
                                          UnitFlags.PetInCombat | UnitFlags.Flag_12_0x1000 | UnitFlags.Silenced |
                                          UnitFlags.Flag_14_0x4000 | UnitFlags.Flag_15_0x8000 |
                                          UnitFlags.SelectableNotAttackable_3 | UnitFlags.Combat |
                                          UnitFlags.TaxiFlight | UnitFlags.Disarmed | UnitFlags.Confused |
                                          UnitFlags.Feared | UnitFlags.NotSelectable | UnitFlags.Skinnable |
                                          UnitFlags.Mounted | UnitFlags.Flag_28_0x10000000 |
                                          UnitFlags.Flag_29_0x20000000 | UnitFlags.Flag_30_0x40000000 |
                                          UnitFlags.Flag_31_0x80000000;
            }

            --this.Vehicle._passengerCount;
            if (this._passenger.MovementFlags.HasFlag((Enum)MovementFlags.Flying))
            {
                SpellCast spellCast = this.Vehicle.SpellCast;
                if (spellCast != null)
                {
                    spellCast.Trigger(SpellId.EffectParachute);
                }
            }

            this._passenger.MovementFlags &= MovementFlags.MaskMoving | MovementFlags.PitchUp |
                                             MovementFlags.PitchDown | MovementFlags.WalkMode |
                                             MovementFlags.DisableGravity | MovementFlags.Root |
                                             MovementFlags.PendingStop | MovementFlags.PendingStrafeStop |
                                             MovementFlags.PendingForward | MovementFlags.PendingBackward |
                                             MovementFlags.PendingStrafeLeft | MovementFlags.PendingStrafeRight |
                                             MovementFlags.PendingRoot | MovementFlags.Swimming | MovementFlags.CanFly |
                                             MovementFlags.Flying | MovementFlags.SplineElevation |
                                             MovementFlags.SplineEnabled | MovementFlags.Waterwalking |
                                             MovementFlags.CanSafeFall | MovementFlags.Hover | MovementFlags.LocalDirty;
            this._passenger.Auras.RemoveFirstVisibleAura((Predicate <Aura>)(aura => aura.Spell.IsVehicle));
            if (this._passenger is Character)
            {
                Character passenger = (Character)this._passenger;
                VehicleHandler.Send_SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA(passenger);
                MovementHandler.SendMoved(passenger);
                MiscHandler.SendCancelAutoRepeat((IPacketReceiver)passenger, (IEntity)this.Vehicle);
                PetHandler.SendEmptySpells((IPacketReceiver)passenger);
                passenger.ResetMover();
                passenger.FarSight = EntityId.Zero;
            }

            this._passenger.m_vehicleSeat = (VehicleSeat)null;
            MovementHandler.SendHeartbeat(this._passenger, this._passenger.Position, this._passenger.Orientation);
            this._passenger.DecMechanicCount(SpellMechanic.Rooted, true);
            this._passenger.HasPermissionToMove = true;
            this._passenger.MovementFlags      &= MovementFlags.MaskMoving | MovementFlags.PitchUp |
                                                  MovementFlags.PitchDown | MovementFlags.WalkMode |
                                                  MovementFlags.OnTransport | MovementFlags.DisableGravity |
                                                  MovementFlags.PendingStop | MovementFlags.PendingStrafeStop |
                                                  MovementFlags.PendingForward | MovementFlags.PendingBackward |
                                                  MovementFlags.PendingStrafeLeft | MovementFlags.PendingStrafeRight |
                                                  MovementFlags.PendingRoot | MovementFlags.Swimming | MovementFlags.CanFly |
                                                  MovementFlags.Flying | MovementFlags.SplineElevation |
                                                  MovementFlags.SplineEnabled | MovementFlags.Waterwalking |
                                                  MovementFlags.CanSafeFall | MovementFlags.Hover | MovementFlags.LocalDirty;
            this._passenger = (Unit)null;
        }