private async Task Fighting(NpcEntity npc, PlayerEntity player) { var npcFightingPlayerId = await _redisDb.StringGet <int>(string.Format(RedisKey.NpcFighting, npc.Id)); if (npcFightingPlayerId != player.Id) { await _mudProvider.ShowMessage(player.Id, $"【切磋】{npcFightingPlayerId},{player.Id},{npc.Id}"); await StopAction(npc.Id); return; } await _mudProvider.ShowMessage(player.Id, $"【切磋】[{npc.Name}]正在攻击你。。。"); await _mudProvider.AddFightingTarget(player.Id, new FightingTargetModel { TargetId = npc.Id, TargetName = npc.Name, Hp = npc.Hp, Mp = npc.Mp, MaxHp = npc.MaxHp, MaxMp = npc.MaxMp, TargetType = TargetTypeEnum.Npc }); }
public AbnormalityStorage Clone(NpcEntity boss, long begin = 0, long end = 0) { Dictionary <NpcEntity, Dictionary <HotDot, AbnormalityDuration> > npcTimes; if (boss != null) { npcTimes = NpcAbnormalityTime.Where(x => x.Key == boss) .ToDictionary(y => y.Key, y => y.Value.ToDictionary(x => x.Key, x => x.Value.Clone(begin, end))); } else { npcTimes = NpcAbnormalityTime .ToDictionary(y => y.Key, y => y.Value.ToDictionary(x => x.Key, x => x.Value.Clone(begin, end))); } var playerTimes = PlayerAbnormalityTime.ToDictionary(y => y.Key, y => y.Value.ToDictionary(x => x.Key, x => x.Value.Clone(begin, end))); var playerDeath = PlayerDeath.ToDictionary(x => x.Key, x => x.Value.Clone(begin, end)); Dictionary <Player, Dictionary <NpcEntity, Death> > playerAggro; if (boss != null) { playerAggro = PlayerAggro.Where(x => x.Value.Keys.Contains(boss)) .ToDictionary(y => y.Key, y => y.Value.Where(x => x.Key == boss).ToDictionary(x => x.Key, x => x.Value.Clone(begin, end))); } else { playerAggro = PlayerAggro .ToDictionary(y => y.Key, y => y.Value.ToDictionary(x => x.Key, x => x.Value.Clone(begin, end))); } return(new AbnormalityStorage(npcTimes, playerTimes, playerDeath, playerAggro)); }
public EntityInformation(NpcEntity entity, long totalDamage, long beginTime, long endTime) { Entity = entity; TotalDamage = totalDamage; BeginTime = beginTime; EndTime = endTime; }
private PlayerInfo GetOrCreate(SkillResult skillResult) { NpcEntity npctarget = skillResult.Target as NpcEntity; if (npctarget != null) { if (OnlyBosses)//not count bosses { if (!npctarget.Info.Boss) { return(null); } } if (IgnoreOneshots)//ignore damage that is more than 10x times than mob's hp { if ((npctarget.Info.HP > 0) && (npctarget.Info.HP <= skillResult.Damage / 10)) { return(null); } } } var player = skillResult.SourcePlayer; PlayerInfo playerStats = StatsByUser.FirstOrDefault(pi => pi.Player.Equals(player)); if (playerStats == null && (IsFromHealer(skillResult) || //either healer (!IsFromHealer(skillResult) && IsValidAttack(skillResult)))) //or damage from non-healer { playerStats = new PlayerInfo(player, this); StatsByUser.Add(playerStats); } return(playerStats); }
private void SendFightData(NpcEntity npc, string json, int retry = 3) { try { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Add("X-Auth-Token", Token); client.DefaultRequestHeaders.Add("X-Auth-Username", Username); client.DefaultRequestHeaders.Add("X-Local-Time", DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString()); client.Timeout = TimeSpan.FromSeconds(40); var response = client.PostAsync(UploadUrl, new StringContent(json, Encoding.UTF8, "application/json")); var responseObject = JsonConvert.DeserializeObject <Dictionary <string, object> >(response.Result.Content.ReadAsStringAsync().Result); if (responseObject.ContainsKey("id") && ((string)responseObject["id"]).StartsWith("http")) { PacketProcessor.Instance.BossLink.TryAdd((string)responseObject["id"], npc); } else { PacketProcessor.Instance.BossLink.TryAdd( "!" + Guid + " " + (string)responseObject["message"] + " " + npc.Info.Name + " " + DateTime.UtcNow.Ticks, npc); } } } catch { //Network issue or server respond with shitty value //TODO logs if (retry <= 1) { throw; } Thread.Sleep(10000); SendFightData(npc, json, --retry); } }
public static void ManualExport(NpcEntity entity, AbnormalityStorage abnormality, Dest type) { if (entity == null) { return; } var stats = GenerateStats(entity, abnormality); if (stats == null) { return; } var sendThread = new Thread(() => { if (type.HasFlag(Dest.Site) && PacketProcessor.Instance.BossLink.Any(x => x.Value == entity && x.Key.StartsWith("!"))) { DpsServers.Where(x => PacketProcessor.Instance.BossLink.Where(y => y.Value == entity && y.Key.StartsWith("!")) .Select(y => y.Key.Substring(1, y.Key.IndexOf(" ", StringComparison.Ordinal) - 1)) .Contains(x.Guid.ToString())).ToList().ForEach(x => x.CheckAndSendFightData(stats.BaseStats, entity)); } if (type.HasFlag(Dest.Excel)) { ExcelExporter.ExcelSave(stats, stats.BaseStats.members.Select(x => x.playerName) .FirstOrDefault(x => PacketProcessor.Instance.MeterPlayers.Select(z => z.Name).Contains(x)), type.HasFlag(Dest.Manual)); } }); sendThread.Start(); }
private async Task FightingNpc(PlayerEntity player, NpcEntity npc) { var actionPoint = await _redisDb.StringGet <int>(string.Format(RedisKey.ActionPoint, player.Id)); if (actionPoint < 10) { actionPoint++; } Random random = new Random(); actionPoint -= random.Next(0, 4); if (actionPoint <= 0) { actionPoint = 0; } await _redisDb.StringSet(string.Format(RedisKey.ActionPoint, player.Id), actionPoint); await _mudProvider.ShowActionPoint(player.Id, actionPoint); await _mudProvider.ShowMessage(player.Id, $"【切磋】你正在攻击[{npc.Name}]。。。"); await _mudProvider.AddFightingTarget(player.Id, new FightingTargetModel { TargetId = npc.Id, TargetName = npc.Name, Hp = npc.Hp, Mp = npc.Mp, MaxHp = npc.MaxHp, MaxMp = npc.MaxMp, TargetType = TargetTypeEnum.Npc }); }
public static void AutomatedExport(NpcEntity entity, AbnormalityStorage abnormality) { if (entity == null) { return; } var stats = GenerateStats(entity, abnormality); if (stats == null) { return; } JsonExporter.JsonSave(stats, PacketProcessor.Instance.EntityTracker.MeterUser.Name); var sendThread = new Thread(() => { DpsServers.Where(x => !x.AnonymousUpload).ToList().ForEach(x => x.CheckAndSendFightData(stats.BaseStats, entity)); ExcelExporter.ExcelSave(stats, PacketProcessor.Instance.EntityTracker.MeterUser.Name); Anonymize(stats.BaseStats); DpsServers.Where(x => x.AnonymousUpload).ToList().ForEach(x => x.CheckAndSendFightData(stats.BaseStats, entity)); if (BasicTeraData.Instance.WindowData.PacketsCollect) { try { PacketsExporter.Instance.Export(stats.BaseStats, entity); } catch (Exception ex) { BasicTeraData.LogError("##### Packets export EXCEPTION #####\r\n" + ex.Message + "\r\n" + ex.StackTrace + "\r\n" + ex.Source + "\r\n" + ex + "\r\n" + ex.Data + "\r\n" + ex.InnerException + "\r\n" + ex.TargetSite); } } }); sendThread.Start(); }
public List <PlayerDamageDealt> PlayerDamageInformation(NpcEntity target) { SQLiteCommand command; string sql; if (target == null) { sql = "SELECT SUM(amount) as total_amount, SUM(case when critic=1 then amount else NULL end) as crit_amount, MIN(time) as start_time, MAX(time) as end_time, SUM(critic) as number_critics, COUNT(case when hotdot=0 then 1 else NULL end) AS number_hits, sourceServerIdPlayerId " + "FROM skills WHERE type = $type AND sourceServerIdPlayerId IS NOT NULL GROUP BY sourceServerIdPlayerId ORDER BY `total_amount` DESC;"; command = new SQLiteCommand(sql, Connexion); command.Parameters.AddWithValue("$type", Type.Damage); return(PlayerDamageInformation(command)); } sql = "SELECT SUM(amount) as total_amount, SUM(case when critic=1 then amount else NULL end) as crit_amount, MIN(time) as start_time, MAX(time) as end_time, SUM(critic) as number_critics, COUNT(case when hotdot=0 then 1 else NULL end) AS number_hits, sourceServerIdPlayerId " + "FROM skills " + "WHERE target = $target AND type = $type AND sourceServerIdPlayerId IS NOT NULL " + "GROUP BY sourceServerIdPlayerId " + "ORDER BY `total_amount` DESC;"; command = new SQLiteCommand(sql, Connexion); command.Parameters.AddWithValue("$target", target.Id.Id); command.Parameters.AddWithValue("$type", Type.Damage); return(PlayerDamageInformation(command)); }
public static void ManualExport(NpcEntity entity, AbnormalityStorage abnormality, Dest type) { if (entity == null) { return; } var stats = GenerateStats(entity, abnormality); if (stats == null) { return; } var sendThread = new Thread(() => { if (type.HasFlag(Dest.Site) && NetworkController.Instance.BossLink.Any(x => x.Value == entity && x.Key.StartsWith("!0"))) { ToTeraDpsApi(stats.BaseStats, entity); } if (type.HasFlag(Dest.Site) && NetworkController.Instance.BossLink.Any(x => x.Value == entity && x.Key.StartsWith("!") && !x.Key.StartsWith("!0"))) { ToPrivateServer(stats.BaseStats, entity, NetworkController.Instance.BossLink.Where(x => x.Value == entity && x.Key.StartsWith("!") && !x.Key.StartsWith("!0")).Select(x => int.Parse(x.Key.Substring(1, x.Key.IndexOf(" ") - 1))).ToList()); } if (type.HasFlag(Dest.Excel)) { ExcelExport.ExcelSave(stats, stats.BaseStats.members.Select(x => x.playerName).FirstOrDefault(x => NetworkController.Instance.MeterPlayers.Select(z => z.Name).Contains(x)), type.HasFlag(Dest.Manual)); } }); sendThread.Start(); }
public void NpcMove(NpcEntity npc) { if (npc.health.health > 0) { SavePosition(npc); if (npc.canMove && npc.projectileToFire == null) { if (npc.moveCooldown > 0) { npc.moveCooldown--; } else { Vector3 newPos = npc.transform.position + RandomDirection(); GameObject targetObj = CanMove(newPos); if (targetObj != null && targetObj.layer == 8 && targetObj.layer != 10) // tile and not unit { SavePosition(npc); npc.transform.LookAt(newPos); npc.health.anim.SetTrigger("Move"); StartCoroutine(NpcMoveSmooth(npc, newPos)); } } } npc.canMove = true; } }
public void Update(SpawnNpcServerMessage m) { var newEntity = new NpcEntity(m.Id, m.OwnerId, GetOrPlaceholder(m.OwnerId), _npcDatabase.GetOrPlaceholder(m.NpcArea, m.NpcId), m.Position, m.Heading); Register(newEntity); }
internal Player Last(NpcEntity entity) { Player result; LastAggro.TryGetValue(entity, out result); return(result); }
public static void ManualExport(NpcEntity entity, AbnormalityStorage abnormality, Dest type) { if (entity == null) { return; } var stats = GenerateStats(entity, abnormality); if (stats == null) { return; } var name = stats.BaseStats.members.Select(x => x.playerName).FirstOrDefault(x => PacketProcessor.Instance.MeterPlayers.Select(z => z.Name).Contains(x)); if (type.HasFlag(Dest.Json)) { JsonExporter.JsonSave(stats, name, type.HasFlag(Dest.Manual)); } var sendThread = new Thread(() => { if (type.HasFlag(Dest.Site) && PacketProcessor.Instance.BossLink.Any(x => x.Value == entity && !x.Key.Success)) { DpsServers.Where(x => PacketProcessor.Instance.BossLink.Where(y => y.Value == entity && !y.Key.Success) .Select(y => y.Key.Server) .Contains(x.Data.HostName)).ToList().ForEach(x => x.CheckAndSendFightData(stats.BaseStats, entity)); } if (type.HasFlag(Dest.Excel)) { ExcelExporter.ExcelSave(stats, name, type.HasFlag(Dest.Manual)); } }); sendThread.Start(); }
internal Dictionary <HotDot, AbnormalityDuration> AbnormalityTime(NpcEntity entity) { if (!NpcAbnormalityTime.ContainsKey(entity)) { NpcAbnormalityTime.Add(entity, new Dictionary <HotDot, AbnormalityDuration>()); } return(NpcAbnormalityTime[entity]); }
private void OnUpdateNpcState(uint id, Coordinate coord, byte life) { Logger.Write("Updating NPC {0}, ({1},{2}), Life:{3}", id, coord.X, coord.Y, life); NpcEntity npc = _gameThread.GameData.Npcs[id]; npc.Location = coord; npc.Life = life; }
private async Task DoCommand(PlayerEntity player, NpcEntity npc, int scriptId, string command, List <CaseAttribute> attrs, string input) { var title = attrs.FirstOrDefault(x => x.Attr == "Title")?.Val; var message = attrs.FirstOrDefault(x => x.Attr == "Message")?.Val; var tips = attrs.FirstOrDefault(x => x.Attr == "Tips")?.Val; int.TryParse(attrs.FirstOrDefault(x => x.Attr == "CommandId")?.Val, out int commandId); int.TryParse(attrs.FirstOrDefault(x => x.Attr == "QuestId")?.Val, out int questId); var key = $"commandIds_{player.Id}_{npc.Id}_{scriptId}"; var commandIds = await _redisDb.StringGet <List <int> >(key) ?? new List <int>(); if (commandId > 0 && !commandIds.Contains(commandId)) { commandIds.Add(commandId); } await _redisDb.StringSet(key, commandIds); var commandEnum = (CommandTypeEnum)Enum.Parse(typeof(CommandTypeEnum), command, true); //await _bus.RaiseEvent(new DomainNotification($"command= {command}")); switch (commandEnum) { case CommandTypeEnum.播放对话: await _mudProvider.ShowMessage(player.Id, $"{npc.Name}:{message}", MessageTypeEnum.聊天); break; case CommandTypeEnum.对话选项: await _mudProvider.ShowMessage(player.Id, $" → <a href='javascript:;' class='chat' npcId='{npc.Id}' scriptId='{scriptId}' commandId='{commandId}'>{title}</a><br />", MessageTypeEnum.指令); break; case CommandTypeEnum.输入选项: await _mudProvider.ShowMessage(player.Id, $" → <a href = 'javascript:;'>{tips}</a> <input type = 'text' name='input' style='width:120px;margin-left:10px;' /> <button type = 'button' class='input' style='padding:1px 3px;' npcId='{npc.Id}' scriptId='{scriptId}' commandId='{commandId}'> 确定 </button><br />", MessageTypeEnum.指令); break; case CommandTypeEnum.跳转到分支: await DoScript(player, npc, scriptId, commandId); break; case CommandTypeEnum.领取任务: await TakeQuest(player, questId); break; case CommandTypeEnum.完成任务: await ComplateQuest(player, questId); break; } }
private static void ToTeraDpsApi(EncounterBase teradpsData, NpcEntity entity) { if (!BasicTeraData.Instance.WindowData.SiteExport) { return; } var areaId = int.Parse(teradpsData.areaId); if ( //areaId != 886 && //areaId != 467 && //areaId != 767 && //areaId != 768 && //areaId != 468 && areaId != 770 && areaId != 769 && areaId != 916 && areaId != 969 && areaId != 970 && areaId != 710 && !(areaId == 950 && int.Parse(teradpsData.bossId) / 100 != 11) ) { return; } long timediff; try { using (var client = new HttpClient()) { client.Timeout = TimeSpan.FromSeconds(40); var response = client.GetAsync("https://moongourd.com/shared/servertime"); timediff = (response.Result.Headers.Date.Value.UtcDateTime.Ticks - DateTime.UtcNow.Ticks) / TimeSpan.TicksPerSecond; teradpsData.encounterUnixEpoch += timediff; } } catch { Debug.WriteLine("Get server time error"); NetworkController.Instance.BossLink.TryAdd( "!0 " + LP.TeraDpsIoApiError + " " + entity.Info.Name + " " + entity.Id + " " + DateTime.UtcNow.Ticks, entity); return; } var json = JsonConvert.SerializeObject(teradpsData, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, TypeNameHandling = TypeNameHandling.None }); teradpsData.encounterUnixEpoch -= timediff; SendTeraDpsIo(entity, json, 3); DELETEME(entity, json); }
public void AggroEnd(Player player, NpcEntity target, long end) { if (PlayerAggro.ContainsKey(player)) { if (PlayerAggro[player].ContainsKey(target)) { PlayerAggro[player][target].End(end); } } }
public Death Aggro(NpcEntity entity) { Death death = null; if (entity != null) { _aggro.TryGetValue(entity, out death); } return(death ?? new Death()); }
private PlayerInfo GetOrCreate(SkillResult skillResult) { NpcEntity npctarget = skillResult.Target as NpcEntity; //ignore pvp if onlybosses is ticked if (OnlyBosses && npctarget == null && IsValidAttack(skillResult)) { return(null); } if (npctarget != null) { if (OnlyBosses)//not count bosses { if (!npctarget.Info.Boss) { return(null); } } if (IgnoreOneshots) { if ((npctarget.Info.HP > 0) //ignore damage that is more than 10x times than mob's hp && (npctarget.Info.HP <= skillResult.Damage / 10 //ignore damage over 100m on a boss || (npctarget.Info.Boss && skillResult.Damage > 99999999))) { return(null); } } } var player = skillResult.SourcePlayer; PlayerInfo playerStats = StatsByUser.FirstOrDefault(pi => pi.Player.Equals(player)); if (playerStats == null && (IsFromHealer(skillResult) || //either healer (!IsFromHealer(skillResult) && IsValidAttack(skillResult)))) //or damage from non-healer { playerStats = new PlayerInfo(player, this); StatsByUser.Add(playerStats); } //update primary target if it's a mob if (npctarget != null) { if (!_targetHitCount.ContainsKey(npctarget)) { _targetHitCount.Add(npctarget, 0); } _targetHitCount[npctarget]++; PrimaryTarget = _targetHitCount.Aggregate((l, r) => l.Value > r.Value ? l : r).Key; } return(playerStats); }
public void UpdateCurrentBoss(NpcEntity entity) { if (!entity.Info.Boss) { return; } if (NetworkController.Instance.Encounter != entity) { NetworkController.Instance.NewEncounter = entity; } }
private static void SendTeraDpsIo(NpcEntity boss, string json, int numberTry, int server = 0) { var url = server == 0 ? "https://moongourd.com/dpsmeter_data.php" : BasicTeraData.Instance.WindowData.PrivateDpsServers[server - 1]; Debug.WriteLine(json); if (numberTry == 0) { Console.WriteLine("API ERROR"); NetworkController.Instance.BossLink.TryAdd( "!" + server + " " + LP.TeraDpsIoApiError + " " + boss.Info.Name + " " + boss.Id + " " + DateTime.UtcNow.Ticks, boss); return; } try { using (var client = new HttpClient()) { //client.DefaultRequestHeaders.Add("X-Auth-Token", BasicTeraData.Instance.WindowData.TeraDpsToken); //client.DefaultRequestHeaders.Add("X-User-Id", BasicTeraData.Instance.WindowData.TeraDpsUser); client.DefaultRequestHeaders.Add("X-Local-Time", DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString()); client.Timeout = TimeSpan.FromSeconds(40); var response = client.PostAsync(url, new StringContent( json, Encoding.UTF8, "application/json") ); var responseString = response.Result.Content.ReadAsStringAsync(); Debug.WriteLine(responseString.Result); var responseObject = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseString.Result); if (responseObject.ContainsKey("id") && ((string)responseObject["id"]).StartsWith("http")) { NetworkController.Instance.BossLink.TryAdd((string)responseObject["id"], boss); } else { NetworkController.Instance.BossLink.TryAdd( "!" + server + " " + (string)responseObject["message"] + " " + boss.Info.Name + " " + boss.Id + " " + DateTime.UtcNow.Ticks, boss); } } } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.StackTrace); Thread.Sleep(10000); SendTeraDpsIo(boss, json, numberTry - 1, server); } }
public void AggroStart(Player player, NpcEntity target, long start) { if (!PlayerAggro.ContainsKey(player)) { PlayerAggro.Add(player, new Dictionary <NpcEntity, Death>()); } if (!PlayerAggro[player].ContainsKey(target)) { PlayerAggro[player][target] = new Death(); } PlayerAggro[player][target].Start(start); }
public Dictionary <HotDot, AbnormalityDuration> Get(NpcEntity entity) { if (entity == null) { return(new Dictionary <HotDot, AbnormalityDuration>()); } if (!NpcAbnormalityTime.ContainsKey(entity)) { return(new Dictionary <HotDot, AbnormalityDuration>()); } return(NpcAbnormalityTime[entity]); }
IEnumerator NpcMoveSmooth(NpcEntity npc, Vector3 newPos) { for (int t = 0; t < 10; t++) { npc.transform.position = Vector3.Lerp(npc.transform.position, newPos, 0.5f); npc.canvas.transform.position = npc.transform.position + npc.canvasOffset; yield return(new WaitForSeconds(0.01f)); } npc.transform.position = newPos; SavePosition(npc); }
private void OnAddNpcEvent(NpcEntity npc) { //Logger.Write("Adding new NPC {0}", npc); if (_gameThread.GameData.Npcs.ContainsKey(npc.Id)) { _gameThread.GameData.Npcs[npc.Id] = npc; } else { _gameThread.GameData.Npcs.Add(npc.Id, npc); } }
private void UpdateComboboxEncounter(IReadOnlyList <NpcEntity> entities, NpcEntity currentBoss) { //http://stackoverflow.com/questions/12164488/system-reflection-targetinvocationexception-occurred-in-presentationframework if (ListEncounter == null || !ListEncounter.IsLoaded) { return; } if (!NeedUpdateEncounter(entities)) { ChangeEncounterSelection(currentBoss); return; } NpcEntity selectedEntity = null; if ((ComboBoxItem)ListEncounter.SelectedItem != null && !(((ComboBoxItem)ListEncounter.SelectedItem).Content is string)) { selectedEntity = (NpcEntity)((ComboBoxItem)ListEncounter.SelectedItem).Content; } ListEncounter.Items.Clear(); ListEncounter.Items.Add(new ComboBoxItem { Content = LP.TotalEncounter }); var selected = false; foreach (var entity in entities) { var item = new ComboBoxItem { Content = entity }; ListEncounter.Items.Add(item); if (entity != selectedEntity) { continue; } ListEncounter.SelectedItem = item; selected = true; } if (ChangeEncounterSelection(currentBoss)) { return; } if (selected) { return; } ListEncounter.SelectedItem = ListEncounter.Items[0]; }
private static void ToPrivateServer(EncounterBase teradpsData, NpcEntity entity, List <int> serverlist = null) { if (!BasicTeraData.Instance.WindowData.PrivateServerExport) { return; } var areaId = int.Parse(teradpsData.areaId); if (areaId != 886 && areaId != 467 && areaId != 767 && areaId != 768 && areaId != 470 && areaId != 468 && areaId != 770 && areaId != 769 && areaId != 916 && areaId != 969 && areaId != 970 && areaId != 710 && areaId != 780 && areaId != 980 && areaId != 781 && areaId != 981 && areaId != 950) { return; } var j = BasicTeraData.Instance.WindowData.PrivateDpsServers.Count; for (var i = 0; i < j; i++) { if (serverlist != null && !serverlist.Contains(i + 1)) { continue; } long timediff; try { var url = new Uri(BasicTeraData.Instance.WindowData.PrivateDpsServers[i]).GetLeftPart(UriPartial.Authority); using (var client = new HttpClient()) { client.Timeout = TimeSpan.FromSeconds(40); var response = client.GetAsync(url + "/shared/servertime"); timediff = (response.Result.Headers.Date.Value.UtcDateTime.Ticks - DateTime.UtcNow.Ticks) / TimeSpan.TicksPerSecond; teradpsData.encounterUnixEpoch += timediff; } } catch { Debug.WriteLine("Get server time error"); NetworkController.Instance.BossLink.TryAdd( "!" + (i + 1) + " " + LP.TeraDpsIoApiError + " " + entity.Info.Name + " " + entity.Id + " " + DateTime.UtcNow.Ticks, entity); continue; } var json = JsonConvert.SerializeObject(teradpsData, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, TypeNameHandling = TypeNameHandling.None }); teradpsData.encounterUnixEpoch -= timediff; SendTeraDpsIo(entity, json, 3, i + 1); } }
public HistoryLink(string link, NpcEntity boss) { InitializeComponent(); Boss.Content = boss.Info.Name; Boss.Tag = link; if (link.StartsWith("!")) { Boss.Foreground = Brushes.Red; Boss.ToolTip = link; return; } Link.Source = BasicTeraData.Instance.ImageDatabase.Link.Source; }
protected void NpcAssignment(byte type, List<byte> data) { byte[] packet = data.ToArray(); NpcEntity output; //try //{ BitReader br = new BitReader(data.ToArray()); br.ReadBitsLittleEndian(8); UInt32 id = (uint)br.Read(32); UInt16 npctype = (ushort)br.Read(16); UInt16 x = (ushort)br.Read(16); UInt16 y = (ushort)br.Read(16); byte life = (byte)br.Read(8); byte size = (byte)br.Read(8); output = new NpcEntity(id, npctype, life, x, y); int informationLength = 16; String[] entries; if (!DataManager.Instance.m_monsterFields.Get(npctype, out entries)) Logger.Write("Failed to read monstats data for NPC of type {0}", type); if (entries.Length != informationLength) Logger.Write("Invalid monstats entry for NPC of type {0}", type); bool lookupName = false; if (data.Count > 0x10) { br.Read(4); if (br.ReadBit()) { for (int i = 0; i < informationLength; i++) { int temp; int value = Int32.Parse(entries[i]); if (!BitScanReverse(out temp, (uint)value - 1)) temp = 0; if (temp == 31) temp = 0; //Console.WriteLine("BSR: {0} Bitcount: {1}", temp+1, bitCount); int bits = br.Read(temp + 1); } } output.SuperUnique = false; output.HasFlags = br.ReadBit(); if (output.HasFlags) { output.Champion = br.ReadBit(); output.Unique = br.ReadBit(); output.SuperUnique = br.ReadBit(); output.IsMinion = br.ReadBit(); output.Ghostly = br.ReadBit(); //Console.WriteLine("{0} {1} {2} {3} {4}", output.Champion, output.Unique, output.SuperUnique, output.IsMinion, output.Ghostly); } if (output.SuperUnique) { output.SuperUniqueId = br.ReadBitsLittleEndian(16); String name; if (!DataManager.Instance.m_superUniques.Get(output.SuperUniqueId, out name)) { Logger.Write("Failed to lookup super unique monster name for {0}", output.SuperUniqueId); output.Name = "invalid"; } else { output.Name = name; //Console.WriteLine("NPC: {0}", name); } } else lookupName = true; if (data.Count > 17 && lookupName != true && output.Name != "invalid") { output.IsLightning = false; while (true) { byte mod = (byte)br.ReadBitsLittleEndian(8); if (mod == 0) break; if (mod == 0x11) output.IsLightning = true; } } } else lookupName = true; if (lookupName) { String name; if (!DataManager.Instance.m_monsterNames.Get((int)output.Type, out name)) Console.WriteLine("Failed to Look up monster name for {0}", output.Type); else output.Name = name; //Console.WriteLine("NPC: {0}", name); } AddNpcEvent(output); }