private void OnMapJoined(PlayedCharacter character, Map map) { m_checkTimer = character.Bot.CallPeriodically(4 * 1000, CheckMonsters); }
private void CheckRessources() { if (m_stopped) { return; } DisposeTimer(); if (Bot.Character.IsFighting() || Bot.Character.IsUsingInteractive() || Bot.Character.IsMoving()) { Bot.CallDelayed(GatherTickTime, CheckRessources); return; } var ressource = Bot.Character.Map.Interactives.Where(x => x.Type != null && x.Type.id == WHEATH_INTERACTIVE && x.Cell != null && x.EnabledSkills.Count > 0 && x.State == InteractiveState.None && x.Id != m_lastTriedInteractive). OrderBy(x => x.Cell.ManhattanDistanceTo(Bot.Character.Cell)).FirstOrDefault(); if (ressource == null) { // should change map here Bot.CallDelayed(GatherTickTime, CheckRessources); return; } // avoid being stucked m_lastTriedInteractive = ressource.Id; var item = Bot.Character.Inventory.GetItemByTemplate(SCYTHE_ITEM); if (item == null) { Bot.Character.SendMessage("You haven't the farmer tool"); Bot.RemoveFrame <GatherTest>(); Bot.Character.SendMessage("Stop gathering ..."); return; } if (!item.IsEquipped) { if (!Bot.Character.Inventory.Equip(item)) { Bot.Character.SendMessage("Cannot equip the farmer tool"); // todo : determin why ? Bot.CallDelayed(GatherTickTime, CheckRessources); } } else // try to gather the ressource the next tick else the tool wouldn't be equipped { var skill = ressource.EnabledSkills.FirstOrDefault(); if (skill == null) { return; } if (!Bot.Character.UseInteractiveObject(skill)) { Bot.CallDelayed(GatherTickTime, CheckRessources); } else { m_timeoutGatherTimer = Bot.CallDelayed(4000, InteractiveUseTimeout); } } }