public void ChangeMap(string direction, int cellId = -1) { IMapChangement move = null; switch (direction) { case "top": case "up": move = _data.Account.Character.Map.ChangeMap(MapDirectionEnum.North, cellId); break; case "left": move = _data.Account.Character.Map.ChangeMap(MapDirectionEnum.West, cellId); break; case "right": move = _data.Account.Character.Map.ChangeMap(MapDirectionEnum.East, cellId); break; case "bottom": case "down": move = _data.Account.Character.Map.ChangeMap(MapDirectionEnum.South, cellId); break; } if (move == null) { return; } move.PerformChangement(); _data.Account.Character.ScriptManager.WaitingForMapChange = true; }
public void DoAction() { if (Locked) { return; } if (Timer.Enabled) { return; } if (!Launched) { return; } Locked = true; Logger.Default.Log($"DoAction"); using (MapMovement movMap = ParseMove()) { if (movMap == null) { Stop(); return; } StartTimer(); // If Gather on this map and there are resources to be gathered if (movMap.Gather && Account.Character.GatherManager.CanGatherOnMap(RessourcesToGather)) { Account.Character.GatherManager.Gather(RessourcesToGather, false); return; } // If Fight on this map and there are mobs to be fighted else if (movMap.Fight && Account.Character.Map.Monsters.Count > 0) { Account.Character.Fight.FightEnded += Fight_FightEnded; Account.Character.Fight.FightStarted += Fight_FightStarted; Account.Character.Map.LaunchAttack(); return; } else if (movMap.CustomFunction != null && movMap.CustomFunction.Type == DataType.Function) { script.Call(movMap.CustomFunction); //I think it's better to let the DoAction time out just in case. return; } var mapDir = movMap.GetDirectionEnum(Randomizer); if (mapDir == MapDirectionEnum.Invalid) // there is no present movement on the script. { return; } else { IMapChangement mapChangement = Account.Character.Map.ChangeMap(mapDir); mapChangement.ChangementFinished += MapChangement_ChangementFinished; mapChangement.PerformChangement(); Locked = true; } } }
public void DoAction() { if (!Launched) { return; } IMapChangement mapChangement = null; if (PathData.ContainsKey(Account.Character.MapId)) { switch (PathData[Account.Character.MapId].Item2) { case "move": Logger.Default.Log($"[PathManager] Déplacement vers {PathData[Account.Character.MapId].Item1}", LogMessageType.Info); mapChangement = Account.Character.Map.ChangeMap(PathData[Account.Character.MapId].Item1); break; case "gather": if (Account.Character.GatherManager.CanGatherOnMap(RessourcesToGather)) { Logger.Default.Log("Lancement de la récolte"); Account.Character.GatherManager.Gather(RessourcesToGather, false); break; } Logger.Default.Log("Rien a récolter"); mapChangement = Account.Character.Map.ChangeMap(PathData[Account.Character.MapId].Item1); break; case "fight": Logger.Default.Log("[PathManager] Combat non géré", LogMessageType.Public); mapChangement = Account.Character.Map.ChangeMap(PathData[Account.Character.MapId].Item1); break; } } else { Logger.Default.Log($"Map {Account.Character.MapId} non gérée dans le trajet"); } if (mapChangement == null) { return; } mapChangement.ChangementFinished += delegate(object sender, MapChangementFinishedEventArgs args) { Logger.Default.Log($"Changement de map {args.Success}"); }; mapChangement.PerformChangement(); }
public void ChangeMapButton(MapDirectionEnum direction) { if (Data is null) { Logger.Default.Log($"Bot currently not running", LogMessageType.Error); } if (WaitingForMapChange) { return; } WaitingForMapChange = true; IMapChangement mapChangement = ChangeMap(direction); mapChangement.ChangementFinished += MapChangement_ChangementFinished; mapChangement.PerformChangement(); }
public IMapChangement ChangeMap(MapDirectionEnum direction) { IMapChangement toReturn = null; var neighbourId = -1; var num2 = -1; if (direction == MapDirectionEnum.North) { neighbourId = ((API.Gamedata.D2p.Map)Data).TopNeighbourId; num2 = 64; } else if (direction == MapDirectionEnum.South) { neighbourId = ((API.Gamedata.D2p.Map)Data).BottomNeighbourId; num2 = 4; } else if (direction == MapDirectionEnum.East) { neighbourId = ((API.Gamedata.D2p.Map)Data).RightNeighbourId; num2 = 1; } else if (direction == MapDirectionEnum.West) { neighbourId = ((API.Gamedata.D2p.Map)Data).LeftNeighbourId; num2 = 16; } if (num2 != -1 && neighbourId >= 0) { var list = new List <int>(); var num4 = ((API.Gamedata.D2p.Map)Data).Cells.Count - 1; for (var i = 0; i < num4; i++) { if ((((API.Gamedata.D2p.Map)Data).Cells[i].MapChangeData & num2) > 0 && NothingOnCell(i)) { list.Add(i); } } var randomCellId = list[Randomize.GetRandomNumber(0, list.Count)]; var move = MoveToCell(randomCellId); toReturn = new MapChangement(_account, move, neighbourId, _account.Character.CellId); return(toReturn); } return(toReturn); }
public void OnCommand(IAccount account, string[] args) { if (args.Length < 1) { Logger.Default.Log("Vous devez spécifier la direction pour changer de map (left, right, top, bottom).", LogMessageType.Public); } else { IMapChangement move = null; switch (args[0]) { case "top": case "up": move = account.Character.Map.ChangeMap(MapDirectionEnum.North); break; case "left": move = account.Character.Map.ChangeMap(MapDirectionEnum.West); break; case "right": move = account.Character.Map.ChangeMap(MapDirectionEnum.East); break; case "bottom": case "bot": move = account.Character.Map.ChangeMap(MapDirectionEnum.South); break; } if (move == null) { return; } move.ChangementFinished += OnChangementFinished; move.PerformChangement(); } }