Exemple #1
0
        private void ItemTransferInternal(ObjectGuid woGuid, ObjectGuid containerGuid, int placement = 0)
        {
            Container container = GetObject(containerGuid) as Container;

            ItemTransferContainerInternal(woGuid, container, placement);
        }
Exemple #2
0
        private Position GetWorldObjectPosition(ObjectGuid objectId)
        {
            Log($"Getting WorldObject Position {objectId.Full:X}");

            return(worldObjects.ContainsKey(objectId) ? worldObjects[objectId].Location : null);
        }
Exemple #3
0
 public WeenieType GetWeenieType(ObjectGuid guid)
 {
     return(worldObjects.ContainsKey(guid) ? worldObjects[guid].WeenieType : 0);
 }
Exemple #4
0
 /// <summary>
 /// Should only be called by physics/relocation engines -- not from player
 /// </summary>
 /// <param name="objectId"></param>
 /// <param name="adjacencyMove"></param>
 public void RemoveWorldObjectForPhysics(ObjectGuid objectId, bool adjacencyMove)
 {
     RemoveWorldObjectInternal(objectId, adjacencyMove);
 }
Exemple #5
0
 public Creature(ObjectType type, ObjectGuid guid, string name, ushort weenieClassId, ObjectDescriptionFlag descriptionFlag, WeenieHeaderFlag weenieFlag, Position position)
     : base(type, guid, name, weenieClassId, descriptionFlag, weenieFlag, position)
 {
 }
Exemple #6
0
        /// <summary>
        /// This method processes the Stackable Merge Game Action (F7B1) Stackable Merge (0x0054)
        /// </summary>
        /// <param name="session">Session is used for sequence and target</param>
        /// <param name="mergeFromGuid">Guid of the item are we merging from</param>
        /// <param name="mergeToGuid">Guid of the item we are merging into</param>
        /// <param name="amount">How many are we merging fromGuid into the toGuid</param>
        public void HandleActionStackableMerge(Session session, ObjectGuid mergeFromGuid, ObjectGuid mergeToGuid, uint amount)
        {
            new ActionChain(this, () =>
            {
                // is this something I already have? If not, it has to be a pickup - do the pickup and out.
                if (!HasItem(mergeFromGuid))
                {
                    // This is a pickup into our main pack.
                    session.Player.HandleActionPutItemInContainer(mergeFromGuid, session.Player.Guid);
                }

                WorldObject fromWo = GetInventoryItem(mergeFromGuid);
                WorldObject toWo   = GetInventoryItem(mergeToGuid);

                if (fromWo == null || toWo == null)
                {
                    return;
                }

                // Check to see if we are trying to merge into a full stack. If so, nothing to do here.
                // Check this and see if I need to call UpdateToStack to clear the action with an amount of 0 Og II
                if (toWo.MaxStackSize == toWo.StackSize)
                {
                    return;
                }

                Debug.Assert(toWo.StackSize != null, "toWo.StackSize != null");
                if (toWo.MaxStackSize >= (ushort)(toWo.StackSize + amount))
                {
                    UpdateToStack(session, fromWo, toWo, amount);
                    // Ok did we merge it all?   If so, let's destroy the from item.
                    if (fromWo.StackSize == amount)
                    {
                        RemoveWorldObject(session, fromWo);
                    }
                    else
                    {
                        UpdateFromStack(session, fromWo, amount);
                    }
                }
                else
                {
                    // ok we have more than the max stack size on the to object, just add what we can and adjust both.
                    Debug.Assert(toWo.MaxStackSize != null, "toWo.MaxStackSize != null");
                    uint amtToFill = (uint)(toWo.MaxStackSize - toWo.StackSize);
                    UpdateToStack(session, fromWo, toWo, amtToFill);
                    UpdateFromStack(session, toWo, amtToFill);
                }
            }).EnqueueChain();
        }
Exemple #7
0
        public override void HandleActionOnCollide(ObjectGuid playerId)
        {
            string serverMessage;

            Player player = CurrentLandblock.GetObject(playerId) as Player;

            if (player == null)
            {
                return;
            }
            if (Destination != null)
            {
#if DEBUG
                serverMessage = "Checking requirements for " + this.Name;
                var usePortalMessage = new GameMessageSystemChat(serverMessage, ChatMessageType.System);
                player.Session.Network.EnqueueSend(usePortalMessage);
#endif
                // Check player level -- requires remote query to player (ugh)...
                if ((player.Level >= MinimumLevel) && ((player.Level <= MaximumLevel) || (MaximumLevel == 0)))
                {
                    Position portalDest = Destination;
                    switch (WeenieClassId)
                    {
                    /// <summary>
                    /// Setup correct racial portal destination for the Central Courtyard in the Training Academy
                    /// </summary>
                    case (ushort)SpecialPortalWCID.CentralCourtyard:
                    {
                        uint playerLandblockId = player.Location.LandblockId.Raw;
                        switch (playerLandblockId)
                        {
                        case (uint)SpecialPortalLandblockID.ShoushiCCLaunch:                // Shoushi
                        {
                            portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.ShoushiCCLanding);
                            break;
                        }

                        case (uint)SpecialPortalLandblockID.YaraqCCLaunch:                // Yaraq
                        {
                            portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.YaraqCCLanding);
                            break;
                        }

                        case (uint)SpecialPortalLandblockID.SanamarCCLaunch:                // Sanamar
                        {
                            portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.SanamarCCLanding);
                            break;
                        }

                        default:                        // Holtburg
                        {
                            portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.HoltburgCCLanding);
                            break;
                        }
                        }

                        portalDest.PositionX = Destination.PositionX;
                        portalDest.PositionY = Destination.PositionY;
                        portalDest.PositionZ = Destination.PositionZ;
                        portalDest.RotationX = Destination.RotationX;
                        portalDest.RotationY = Destination.RotationY;
                        portalDest.RotationZ = Destination.RotationZ;
                        portalDest.RotationW = Destination.RotationW;
                        break;
                    }

                    /// <summary>
                    /// Setup correct racial portal destination for the Outer Courtyard in the Training Academy
                    /// </summary>
                    case (ushort)SpecialPortalWCID.OuterCourtyard:
                    {
                        uint playerLandblockId = player.Location.LandblockId.Raw;
                        switch (playerLandblockId)
                        {
                        case (uint)SpecialPortalLandblockID.ShoushiOCLaunch:                // Shoushi
                        {
                            portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.ShoushiOCLanding);
                            break;
                        }

                        case (uint)SpecialPortalLandblockID.YaraqOCLaunch:                // Yaraq
                        {
                            portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.YaraqOCLanding);
                            break;
                        }

                        case (uint)SpecialPortalLandblockID.SanamarOCLaunch:                // Sanamar
                        {
                            portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.SanamarOCLanding);
                            break;
                        }

                        default:                        // Holtburg
                        {
                            portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.HoltburgOCLanding);
                            break;
                        }
                        }

                        portalDest.PositionX = Destination.PositionX;
                        portalDest.PositionY = Destination.PositionY;
                        portalDest.PositionZ = Destination.PositionZ;
                        portalDest.RotationX = Destination.RotationX;
                        portalDest.RotationY = Destination.RotationY;
                        portalDest.RotationZ = Destination.RotationZ;
                        portalDest.RotationW = Destination.RotationW;
                        break;
                    }

                    /// <summary>
                    /// All other portals don't need adjustments.
                    /// </summary>
                    default:
                    {
                        break;
                    }
                    }

#if DEBUG
                    serverMessage    = "Portal sending player to destination";
                    usePortalMessage = new GameMessageSystemChat(serverMessage, ChatMessageType.System);
                    player.Session.Network.EnqueueSend(usePortalMessage);
#endif
                    player.Session.Player.Teleport(portalDest);
                    // If the portal just used is able to be recalled to,
                    // save the destination coordinates to the LastPortal character position save table
                    if (IsRecallable)
                    {
                        player.SetCharacterPosition(PositionType.LastPortal, portalDest);
                    }
                }
                else if ((player.Level > MaximumLevel) && (MaximumLevel != 0))
                {
                    // You are too powerful to interact with that portal!
                    var failedUsePortalMessage = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_04AC);
                    player.Session.Network.EnqueueSend(failedUsePortalMessage);
                }
                else
                {
                    // You are not powerful enough to interact with that portal!
                    var failedUsePortalMessage = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_04AB);
                    player.Session.Network.EnqueueSend(failedUsePortalMessage);
                }
            }
            else
            {
                serverMessage = "Portal destination for portal ID " + this.WeenieClassId + " not yet implemented!";
                var failedUsePortalMessage = new GameMessageSystemChat(serverMessage, ChatMessageType.System);
                player.Session.Network.EnqueueSend(failedUsePortalMessage);
            }
        }
Exemple #8
0
        public DebugObject(ObjectGuid guid, BaseAceObject baseAceObject)
            : base((ObjectType)baseAceObject.TypeId, guid)
        {
            this.Name = baseAceObject.Name;
            if (this.Name == null)
            {
                this.Name = "NULL";
            }

            this.DescriptionFlags = (ObjectDescriptionFlag)baseAceObject.WdescBitField;
            this.WeenieClassid    = baseAceObject.AceObjectId;
            this.WeenieFlags      = (WeenieHeaderFlag)baseAceObject.WeenieFlags;

            this.PhysicsData.MTableResourceId = baseAceObject.MotionTableId;
            this.PhysicsData.Stable           = baseAceObject.SoundTableId;
            this.PhysicsData.CSetup           = baseAceObject.ModelTableId;
            this.PhysicsData.Petable          = baseAceObject.PhysicsTableId;

            // this should probably be determined based on the presence of data.
            this.PhysicsData.PhysicsDescriptionFlag = (PhysicsDescriptionFlag)baseAceObject.PhysicsBitField;
            this.PhysicsData.PhysicsState           = (PhysicsState)baseAceObject.PhysicsState;

            if (baseAceObject.CurrentMotionState == "0")
            {
                this.PhysicsData.CurrentMotionState = null;
            }
            else
            {
                this.PhysicsData.CurrentMotionState = new UniversalMotion(Convert.FromBase64String(baseAceObject.CurrentMotionState));
            }

            this.PhysicsData.ObjScale       = baseAceObject.ObjectScale;
            this.PhysicsData.AnimationFrame = baseAceObject.AnimationFrameId;
            this.PhysicsData.Translucency   = baseAceObject.Translucency;

            // game data min required flags;
            this.Icon = baseAceObject.IconId;

            if (this.GameData.NamePlural == null)
            {
                this.GameData.NamePlural = "NULLs";
            }

            this.GameData.Type = (ushort)baseAceObject.AceObjectId;

            this.GameData.Usable        = (Usable)baseAceObject.Usability;
            this.GameData.RadarColour   = (RadarColor)baseAceObject.BlipColor;
            this.GameData.RadarBehavior = (RadarBehavior)baseAceObject.Radar;
            this.GameData.UseRadius     = baseAceObject.UseRadius;

            this.GameData.HookType      = (ushort)baseAceObject.HookTypeId;
            this.GameData.HookItemTypes = baseAceObject.HookItemTypes;
            this.GameData.Burden        = (ushort)baseAceObject.Burden;
            this.GameData.Value         = baseAceObject.Value;
            this.GameData.ItemCapacity  = baseAceObject.ItemsCapacity;

            // Put is in for Ripley - these are the fields I want to write that he was concerned with.
            if ((this.Type & (ObjectType.Creature | ObjectType.LifeStone | ObjectType.Portal)) == 0)
            {
                // because this comes from PCAP data - on create we are not animating.
                this.PhysicsData.AnimationFrame = 0x65;

                // I think this is wrong - we need the weenieClassId from weenie_class   Leaving it for now
                // TODO: use view to return the correct value.
                this.WeenieClassid = baseAceObject.AceObjectId;

                // Container will always be 0 or a value and we should write it.
                // Not sure if the align packs us out with 0's may be redundant Og II
                this.WeenieFlags |= WeenieHeaderFlag.Container;

                // Creating from a pcap of the weenie - this will be set by the loot generation factory. Og II
                this.PhysicsData.PhysicsDescriptionFlag &= ~PhysicsDescriptionFlag.Parent;
                this.GameData.ValidLocations             = (EquipMask)baseAceObject.ValidLocations;
                this.GameData.IconOverlay = (ushort)baseAceObject.IconOverlayId;
            }
            if (this.PhysicsData.AnimationFrame != 0)
            {
                this.PhysicsData.PhysicsDescriptionFlag |= PhysicsDescriptionFlag.AnimationFrame;
            }
            this.PhysicsData.DefaultScript          = baseAceObject.DefaultScript;
            this.PhysicsData.DefaultScriptIntensity = baseAceObject.DefaultScriptIntensity;
            this.PhysicsData.Elastcity = baseAceObject.Elasticity;
            this.PhysicsData.EquipperPhysicsDescriptionFlag = EquipMask.Wand;
            this.PhysicsData.Friction = baseAceObject.Friction;

            baseAceObject.AnimationOverrides.ForEach(ao => this.ModelData.AddModel(ao.Index, ao.AnimationId));
            baseAceObject.TextureOverrides.ForEach(to => this.ModelData.AddTexture(to.Index, to.OldId, to.NewId));
            baseAceObject.PaletteOverrides.ForEach(po => this.ModelData.AddPalette(po.SubPaletteId, po.Offset, po.Length));
            this.ModelData.PaletteGuid = baseAceObject.PaletteId;
        }