public static void Clear() { Logger.Log("Limpando variaves globais."); playerCash = 0; playerIcons = 0; playerId = 0; playerPosition = null; for (int i = 0; i < (int)Skills.Last; i++) { for (int j = 0; j < (int)SkillAttribute.Last; j++) { playerSkills[i,j] = 0; } } for (int i = 0; i < (int)PlayerStatus.Last; i++) { playerStatus[i] = 0; } connected = false; canReportBugs = false; playerAddress = 0; attackId = 0; }
public int DistanceTo(Position pos) { if (pos == null || pos.Z != Z) return int.MaxValue; uint xDist = X - pos.X; uint yDist = Y - pos.Y; return (int)Math.Sqrt(xDist * xDist + yDist * yDist); }
private void upDateMap(int x, int y, int z, int width, int height) { Map map = Map.GetInstance(); for (int nx = 0; nx < width; nx++) { for (int ny = 0; ny < height; ny++) { Position pos = new Position((uint)(x + nx), (uint)(y + ny), (uint)z); Tile tile = map.GetTile(pos); miniMap.Matrix[nx, ny] = tile != null ? tile.GetMinimapColor() : Byte.MinValue; } } }
public void SendUseItemWith(Position fromPos, ushort fromItemId, byte fromStackpos, Position toPos, ushort toItemid, byte toStackpos) { lock (serverSendMsg) { serverSendMsg.Reset(); serverSendMsg.AddByte(0x83); serverSendMsg.AddPosition(fromPos); serverSendMsg.AddUInt16(fromItemId); serverSendMsg.AddByte(fromStackpos); serverSendMsg.AddPosition(toPos); serverSendMsg.AddUInt16(toItemid); serverSendMsg.AddByte(toStackpos); send(); } }
public void SendUseItem(Position pos, ushort itemId, byte stackPos) { lock (serverSendMsg) { serverSendMsg.Reset(); serverSendMsg.AddByte(0x82); serverSendMsg.AddPosition(pos); serverSendMsg.AddUInt16(itemId); serverSendMsg.AddByte(stackPos); serverSendMsg.AddByte((byte)Containers.GetInstance().GetFreeContainerSlot()); send(); } }
public void SendUseBattleWindow(Position pos, ushort itemId, byte stackPos, uint creatureId) { lock (serverSendMsg) { serverSendMsg.Reset(); serverSendMsg.AddByte(0x84); serverSendMsg.AddPosition(pos); serverSendMsg.AddUInt16(itemId); serverSendMsg.AddByte(stackPos); serverSendMsg.AddUInt32(creatureId); send(); } }
public void SendLookItem(Position pos, ushort itemId, byte stackPos) { lock (serverSendMsg) { serverSendMsg.Reset(); serverSendMsg.AddByte(0x8C); serverSendMsg.AddPosition(pos); serverSendMsg.AddUInt16(itemId); serverSendMsg.AddByte(stackPos); send(); } }
private bool setTileDescription(NetworkMessage incMsg, NetworkMessage outMsg, Position pos) { //set the tile in the map Tile tile = Map.GetInstance().SetTile(pos); if (tile == null) return false; //and clear it tile.Clear(); int n = 0; while (true) { //avoid infinite loop n++; ushort inspectTileId = incMsg.PeekUInt16(); if (inspectTileId >= 0xFF00) { //end of the tile //Notifications::onTileUpdate(pos); return true; } else { if (n > 10) { Logger.Log("Muitos objetos no tile. Posição: " + pos.ToString(), LogType.ERROR); return false; } //read tile things: items and creatures Thing thing = internalGetThing(incMsg, outMsg); if (thing == null) { Logger.Log("Falha ao obter o objeto. Posição: " + pos.ToString(), LogType.ERROR); return false; } //and add to the tile if (!tile.AddThing(thing)) { Logger.Log("Falha ao adicionar um objeto. Posição: " + pos.ToString(), LogType.ERROR); return false; } } } }
private bool setFloorDescription(NetworkMessage incMsg, NetworkMessage outMsg, int x, int y, int z, int width, int height, int offset) { for (int nx = 0; nx < width; nx++) { for (int ny = 0; ny < height; ny++) { if (skipTiles == 0) { ushort tileOpt = incMsg.PeekUInt16(); //Decide if we have to skip tiles // or if it is a real tile if (tileOpt >= 0xFF00) { ushort skip = incMsg.GetUInt16(); outMsg.AddUInt16(skip); skipTiles = (ushort)(skip & 0xFF); } else { //real tile so read tile Position pos = new Position((uint)(x + nx + offset), (uint)(y + ny + offset), (uint)z); if (!setTileDescription(incMsg, outMsg, pos)) { Logger.Log("Falha ao setar a descrição do tile. Posição: " + pos.ToString(), LogType.ERROR); return false; } //read skip tiles info ushort skip = incMsg.GetUInt16(); outMsg.AddUInt16(skip); skipTiles = (ushort)(skip & 0xFF); } } //skipping tiles... else { skipTiles--; } } } return true; }
public bool Equals(Position pos) { return pos != null && pos.X == X && pos.Y == Y && pos.Z == Z; }
public bool UseItem(Position pos) { Tile tile = Map.GetInstance().GetTile(pos); if(tile == null) { Logger.Log("Falha ao usar o item. Tile igual a null.", LogType.ERROR); return false; } int stackPos = tile.GetUseStackPosition(); Thing thing = tile.GetThingByStackPosition(stackPos); if(thing is Item && stackPos != -1) { Item item = (Item)thing; if(!item.IsExtendedUseable()) { if(kernel.WorldProtocol != null) kernel.WorldProtocol.SendUseItem(pos, (ushort)item.GetId(), (byte)stackPos); else { Logger.Log("Falha ao usar item. Protocol não está iniciado.", LogType.ERROR); return false; } } else { Logger.Log("TODO: Send extended."); } } else { Logger.Log("Falha ao usar o item. Item não encontrado.", LogType.ERROR); return false; } return true; }
public void OnReceivePlayerMove(Position newPosition) { //Logger.Log("Nova Posição: " + newPosition); }
public bool Walk(Position pos) { if(GlobalVariables.IsConnected()) { var Memory = kernel.Client.Memory; Memory.WriteUInt32(Addresses.Player.GoToX, pos.X); Memory.WriteUInt32(Addresses.Player.GoToY, pos.Y); Memory.WriteUInt32(Addresses.Player.GoToZ, pos.Z); Memory.WriteByte(GlobalVariables.GetPlayerMemoryAddress() + Addresses.Creature.DistanceIsWalking, Convert.ToByte(true)); return true; } return false; }
public bool UseItemOn(ushort itemId, Position position) { Tile tile = Map.GetInstance().GetTile(position); if(tile == null) { Logger.Log("Falha ao usar o item. Tile igual a null.", LogType.ERROR); return false; } int stackPos = tile.GetExtendedUseStackPosition(); Thing thing = tile.GetThingByStackPosition(stackPos); if(thing is Item && stackPos != -1) { if(kernel.WorldProtocol != null) kernel.WorldProtocol.SendUseItemWith(new Position(0xFFFF, 0, 0), itemId, 0, position, (ushort)thing.GetId(), (byte)stackPos); } else { Logger.Log("Falha ao usar o item. Item não encontrado.", LogType.ERROR); return false; } return true; }
public void SetPosition(Position position) { this.position = position; }
public static void SetPlayerPosition(Position position) { playerPosition = position; }
public bool IsAdjacentTo(Position pos) { return pos != null && pos.Z == Z && Math.Max(Math.Abs(X - pos.X), Math.Abs(Y - pos.Y)) <= 1; }
public WalkWaypoint(Position pos, WaypointType type) : base(type) { Position = pos; }