private void ParseDeleteInContainer(Internal.CommunicationStream message) { byte containerId = message.ReadUnsignedByte(); ushort slot; Appearances.ObjectInstance appendObject = null; if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameContainerPagination)) { slot = message.ReadUnsignedShort(); ushort itemId = message.ReadUnsignedShort(); if (itemId != 0) { appendObject = ProtocolGameExtentions.ReadObjectInstance(message, itemId); } } else { slot = message.ReadUnsignedByte(); } var containerView = ContainerStorage.GetContainerView(containerId); if (!!containerView) { containerView.RemoveObject(slot, appendObject); } }
private void ParseCreateOnMap(Internal.CommunicationStream message) { var absolutePosition = message.ReadPosition(); if (!WorldMapStorage.IsVisible(absolutePosition, true)) { throw new System.Exception("ProtocolGame.ParseCreateOnMap: Co-ordinate " + absolutePosition + " is out of range."); } var mapPosition = WorldMapStorage.ToMap(absolutePosition); int stackPos = 255; if (OpenTibiaUnity.GameManager.ClientVersion >= 841) { stackPos = message.ReadUnsignedByte(); } int typeOrId = message.ReadUnsignedShort(); Appearances.ObjectInstance @object; if (typeOrId == Appearances.AppearanceInstance.Creature || typeOrId == Appearances.AppearanceInstance.OutdatedCreature || typeOrId == Appearances.AppearanceInstance.UnknownCreature) { var creature = ProtocolGameExtentions.ReadCreatureInstance(message, typeOrId, absolutePosition); if (creature.Id == Player.Id) { Player.StopAutowalk(true); } @object = AppearanceStorage.CreateObjectInstance(Appearances.AppearanceInstance.Creature, creature.Id); } else { @object = ProtocolGameExtentions.ReadObjectInstance(message, typeOrId); } if (stackPos == 255) { WorldMapStorage.PutObject(mapPosition, @object); } else { if (stackPos > Constants.MapSizeW) { throw new System.Exception("ProtocolGame.ParseCreateOnMap: Invalid stack position (" + stackPos + ")."); } WorldMapStorage.InsertObject(mapPosition, stackPos, @object); } if (absolutePosition.z == MiniMapStorage.PositionZ) { WorldMapStorage.UpdateMiniMap(mapPosition); uint color = WorldMapStorage.GetMiniMapColour(mapPosition); int cost = WorldMapStorage.GetMiniMapCost(mapPosition); MiniMapStorage.UpdateField(absolutePosition, color, cost, false); } WorldMapStorage.CacheRefresh = true; }
private void ParseOpenContainer(Internal.CommunicationStream message) { byte containerId = message.ReadUnsignedByte(); var objectIcon = ProtocolGameExtentions.ReadObjectInstance(message); string name = message.ReadString(); byte nOfSlotsPerPage = message.ReadUnsignedByte(); // capacity of shown view bool isSubContainer = message.ReadBoolean(); bool canUseDepotSearch = false; bool isDragAndDropEnabled = true; bool isPaginationEnabled = false; int nOfTotalObjects; int indexOfFirstObject = 0; int nOfContentObjects; // objects in the current shown view // if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameContainerPagination)) { if (OpenTibiaUnity.GameManager.ClientVersion >= 1220) { canUseDepotSearch = message.ReadBoolean(); } isDragAndDropEnabled = message.ReadBoolean(); isPaginationEnabled = message.ReadBoolean(); nOfTotalObjects = message.ReadUnsignedShort(); indexOfFirstObject = message.ReadUnsignedShort(); nOfContentObjects = message.ReadUnsignedByte(); if (nOfContentObjects > nOfSlotsPerPage) { throw new System.Exception("ProtocolGame.ParseOpenContainer: Number of content objects " + nOfContentObjects + " exceeds number of slots per page " + nOfSlotsPerPage); } if (nOfContentObjects > nOfTotalObjects) { throw new System.Exception("ProtocolGame.ParseOpenContainer: Number of content objects " + nOfContentObjects + " exceeds number of total objects " + nOfTotalObjects); } } else { nOfContentObjects = message.ReadUnsignedByte(); nOfTotalObjects = nOfContentObjects; if (nOfContentObjects > nOfSlotsPerPage) { throw new System.Exception("ProtocolGame.ParseOpenContainer: Number of content objects " + nOfContentObjects + " exceeds the capaciy " + nOfSlotsPerPage); } } var containerView = ContainerStorage.CreateContainerView(containerId, objectIcon, name, isSubContainer, isDragAndDropEnabled, isPaginationEnabled, nOfSlotsPerPage, nOfTotalObjects - nOfContentObjects, indexOfFirstObject, nOfContentObjects); for (int i = 0; i < nOfContentObjects; i++) { containerView.AddObject(indexOfFirstObject + i, ProtocolGameExtentions.ReadObjectInstance(message)); } }
public void ParseKillTracking(Internal.CommunicationStream message) { string name = message.ReadString(); var outfit = ProtocolGameExtentions.ReadCreatureOutfit(message); int lootCount = message.ReadUnsignedByte(); for (int i = 0; i < lootCount; i++) { var @object = ProtocolGameExtentions.ReadObjectInstance(message); } }
private void ParseCreateInContainer(Internal.CommunicationStream message) { byte containerId = message.ReadUnsignedByte(); ushort slot = 0; if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameContainerPagination)) { slot = message.ReadUnsignedShort(); } var @object = ProtocolGameExtentions.ReadObjectInstance(message); var containerView = ContainerStorage.GetContainerView(containerId); if (!!containerView) { containerView.AddObject(slot, @object); } }
private void ParseInspectionList(Internal.CommunicationStream message) { bool isPlayer = message.ReadBoolean(); int size = message.ReadUnsignedByte(); for (int i = 0; i < size; i++) { var @object = ProtocolGameExtentions.ReadObjectInstance(message); if (isPlayer) { var slot = message.ReadEnum <ClothSlots>(); } int imbuementSlots = message.ReadUnsignedByte(); for (int j = 0; j < imbuementSlots; j++) { int imbuementId = message.ReadUnsignedByte(); } int details = message.ReadUnsignedByte(); for (int j = 0; j < details; j++) { string name = message.ReadString(); string description = message.ReadString(); } } if (isPlayer) { string playerName = message.ReadString(); var outfit = ProtocolGameExtentions.ReadCreatureOutfit(message); int details = message.ReadUnsignedByte(); for (int j = 0; j < details; j++) { string name = message.ReadString(); string description = message.ReadString(); } } }
private void ParseItemLooted(Internal.CommunicationStream message) { var @object = ProtocolGameExtentions.ReadObjectInstance(message); string name = message.ReadString(); }
private void ParseChangeOnMap(Internal.CommunicationStream message) { int x = message.ReadUnsignedShort(); Appearances.ObjectInstance objectInstance; Creatures.Creature creature = null; UnityEngine.Vector3Int absolutePosition; UnityEngine.Vector3Int mapPosition; if (x != 65535) { absolutePosition = message.ReadPosition(x); if (!WorldMapStorage.IsVisible(absolutePosition, true)) { throw new System.Exception("ProtocolGame.ParseChangeOnMap: Co-ordinate " + absolutePosition + " is out of range."); } mapPosition = WorldMapStorage.ToMap(absolutePosition); int stackPos = message.ReadUnsignedByte(); if (!(objectInstance = WorldMapStorage.GetObject(mapPosition, stackPos))) { throw new System.Exception("ProtocolGame.ParseChangeOnMap: Object not found."); } if (objectInstance.IsCreature && !(creature = CreatureStorage.GetCreature(objectInstance.Data))) { throw new System.Exception("ProtocolGame.ParseChangeOnMap: Creature not found: " + objectInstance.Data); } if (!!creature) { CreatureStorage.MarkOpponentVisible(creature, false); } int typeOrId = message.ReadUnsignedShort(); if (typeOrId == Appearances.AppearanceInstance.UnknownCreature || typeOrId == Appearances.AppearanceInstance.OutdatedCreature || typeOrId == Appearances.AppearanceInstance.Creature) { creature = ProtocolGameExtentions.ReadCreatureInstance(message, typeOrId, absolutePosition); objectInstance = AppearanceStorage.CreateObjectInstance(Appearances.AppearanceInstance.Creature, creature.Id); } else { objectInstance = ProtocolGameExtentions.ReadObjectInstance(message, typeOrId); } WorldMapStorage.ChangeObject(mapPosition, stackPos, objectInstance); } else { uint creatureId = message.ReadUnsignedInt(); if (!(creature = CreatureStorage.GetCreature(creatureId))) { throw new System.Exception("ProtocolGame.ParseChangeOnMap: Creature " + creatureId + " not found"); } absolutePosition = creature.Position; if (!WorldMapStorage.IsVisible(absolutePosition, true)) { throw new System.Exception("ProtocolGame.ParseChangeOnMap: Co-ordinate " + absolutePosition + " is out of range."); } mapPosition = WorldMapStorage.ToMap(absolutePosition); CreatureStorage.MarkOpponentVisible(creature, false); int otherType = message.ReadUnsignedShort(); if (otherType == Appearances.AppearanceInstance.Creature || otherType == Appearances.AppearanceInstance.OutdatedCreature || otherType == Appearances.AppearanceInstance.UnknownCreature) { creature = ProtocolGameExtentions.ReadCreatureInstance(message, otherType); } else { throw new System.Exception("ProtocolGame.ParseChangeOnMap: Received object of type " + otherType + " when a creature was expected."); } } if (absolutePosition.z == MiniMapStorage.PositionZ) { WorldMapStorage.UpdateMiniMap(mapPosition); uint color = WorldMapStorage.GetMiniMapColour(mapPosition); int cost = WorldMapStorage.GetMiniMapCost(mapPosition); MiniMapStorage.UpdateField(absolutePosition, color, cost, false); } WorldMapStorage.CacheRefresh = true; }