public static double GetCellHeight(Map Map, int CellId) { DofusCell cell = Map.getCell(CellId); if (cell == null) { return(0); } else { return((cell.groundSlope == 1 ? (0) : (0.5)) + (cell.groundLevel - 7)); } }
public IObject(Map a_map, DofusCell a_cell, int a_id) { _id = a_id; _map = a_map; _cell = a_cell; _state = (int)IObjectEnum.STATE_FULL; int respawnTime = 10000; _template = IObjectTemplateTable.Get(_id); if (_template != null) { respawnTime = _template.RespawnTime; } if (respawnTime != -1) { _respawnTimer = new Timer(respawnTime); _respawnTimer.Elapsed += new ElapsedEventHandler(_timer_Elapsed); _respawnTimer.Enabled = true; } }
public static Dictionary <int, DofusCell> DecompileMapData(Map map, String dData) { Dictionary <int, DofusCell> cells = new Dictionary <int, DofusCell>(); for (int f = 0; f < dData.Length; f += 10) { String CellData = dData.Substring(f, 10); int[] CellInfo = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; for (int i = 0; i < CellData.Length; i++) { CellInfo[i] = HASH_CELL.IndexOf(CellData[i]); } int Type = (CellInfo[2] & 56) >> 3; Boolean IsSightBlocker = (CellInfo[0] & 1) != 0; int layerObject2 = ((CellInfo[0] & 2) << 12) + ((CellInfo[7] & 1) << 12) + (CellInfo[8] << 6) + CellInfo[9]; Boolean layerObject2Interactive = ((CellInfo[7] & 2) >> 1) != 0; int obj = (layerObject2Interactive ? layerObject2 : -1); Boolean _walkable = ((Type != 0) && ((CellInfo[0] & 32) >> 5) != 0); int GroundSlope = (CellInfo[4] & 60) >> 2; int GroundLevel = CellInfo[1] & 15; var cell = new DofusCell() { Map = map.Id, Id = f / 10, Walkable = _walkable, LoS = IsSightBlocker, groundLevel = GroundLevel, groundSlope = GroundSlope }; if (obj != -1) { cell.Object = new IObject(map, cell, obj); } cells.Add(f / 10, cell); } return(cells); }
public static List <DofusCell> getCellListFromAreaString(Map map, int cellID, int castCellID, String zoneStr, int PONum, Boolean isCC) { List <DofusCell> cases = new List <DofusCell>(); int c = PONum; if (map.getCell(cellID) == null) { return(cases); } cases.Add(map.getCell(cellID)); if (zoneStr.Length < c + 1) { return(cases); } int taille = MapCrypter.HASH.IndexOf(zoneStr[c + 1]); switch (zoneStr[c]) { case 'C': //Cercle for (int a = 0; a < taille; a++) { char[] dirs = { 'b', 'd', 'f', 'h' }; List <DofusCell> cases2 = new List <DofusCell>(); cases.ForEach(x => cases2.Add(x)); foreach (DofusCell aCell in cases2) { foreach (char d in dirs) { DofusCell cell = map.getCell(DirToCellID(aCell.Id, d, map, true)); if (cell == null) { continue; } if (!cases.Contains(cell)) { cases.Add(cell); } } } } break; case 'X': //Croix char[] dirsx = { 'b', 'd', 'f', 'h' }; foreach (char d in dirsx) { int cID = cellID; for (int a = 0; a < taille; a++) { DofusCell cell = map.getCell(DirToCellID(cID, d, map, true)); cID = DirToCellID(cID, d, map, true); if (cell == null) { continue; } cases.Add(cell); } } break; case 'L': //Ligne char dir = getDirBetweenTwoCase(castCellID, cellID, map, true); for (int a = 0; a < taille; a++) { DofusCell cell = map.getCell(DirToCellID(cellID, dir, map, true)); if (cell != null) { cases.Add(cell); } cellID = DirToCellID(cellID, dir, map, true); } break; case 'P': //Player? break; default: Logger.Error("[FIXME]Type de portée non reconnue: " + zoneStr[0]); break; } return(cases); }
public static List <DofusCell> getShortestPathBetween(Map map, int start, int dest, int distMax, Fight fight) { try { List <DofusCell> curPath = new List <DofusCell>(); List <DofusCell> curPath2 = new List <DofusCell>(); List <DofusCell> closeCells = new List <DofusCell>(); int limit = 1000; DofusCell curCase = map.getCell(start); int stepNum = 0; Boolean stop = false; while ((!stop) && (stepNum++ <= limit)) { int nearestCell = getNearestCellAround(map, curCase.Id, dest, closeCells, fight); if (nearestCell == -1) { closeCells.Add(curCase); if (curPath.Count > 0) { curPath.RemoveAt(curPath.Count - 1); if (curPath.Count > 0) { curCase = (DofusCell)curPath.ToArray()[curPath.Count - 1]; } else { curCase = map.getCell(start); } } else { curCase = map.getCell(start); } } else { if ((distMax == 0) && (nearestCell == dest)) { curPath.Add(map.getCell(dest)); break; } if (distMax > GetDistanceBetween(map, nearestCell, dest)) { curPath.Add(map.getCell(dest)); break; } curCase = map.getCell(nearestCell); closeCells.Add(curCase); curPath.Add(curCase); } } curCase = map.getCell(start); closeCells.Clear(); closeCells.Add((DofusCell)curPath.ToArray()[0]); while ((!stop) && (stepNum++ <= limit)) { int nearestCell = getNearestCellAround(map, curCase.Id, dest, closeCells, fight); if (nearestCell == -1) { closeCells.Add(curCase); if (curPath2.Count > 0) { curPath2.RemoveAt(curPath2.Count - 1); if (curPath2.Count > 0) { curCase = (DofusCell)curPath2.ToArray()[curPath2.Count - 1]; } else { curCase = map.getCell(start); } } else { curCase = map.getCell(start); } } else { if ((distMax == 0) && (nearestCell == dest)) { curPath2.Add(map.getCell(dest)); break; } if (distMax > GetDistanceBetween(map, nearestCell, dest)) { curPath2.Add(map.getCell(dest)); break; } curCase = map.getCell(nearestCell); closeCells.Add(curCase); curPath2.Add(curCase); } } if (((curPath2.Count < curPath.Count) && (curPath2.Count > 0)) || (curPath.Count == 0)) { curPath = curPath2; } return(curPath); } catch (Exception e) { } return(null); }