/*private static void DebugPlayerSorting(string header, IEnumerable<VariableClump> vc) * { * int ro = 1; * foreach (VariableClump a in vc) * { * System.Diagnostics.Debug.WriteLine(header + ": " + ro + " -- " + a.GetValue("name") + ", " + a.GetValue("job") + " --> " + a.GetValue("order") + " / " + cfg.GetPartyOrderValue(a.GetValue("jobid"))); * ro++; * } * }*/ public static int SortPlayersSelf(VariableClump a, VariableClump b) { if (a == Myself && b != Myself) { //System.Diagnostics.Debug.WriteLine(a.GetValue("name") + " (ME) < " + b.GetValue("name")); return(-1); } if (b == Myself && a != Myself) { //System.Diagnostics.Debug.WriteLine(a.GetValue("name") + " > " + b.GetValue("name") + " (ME)"); return(1); } return(SortPlayers(a, b)); }
public static VariableClump GetIdEntity(string id, out bool found) { VariableClump vc = new VariableClump(); found = false; try { object plug = null; plug = GetInstance(); if (plug == null) { return(vc); } PropertyInfo pi = GetDataRepository(plug); CombatantData cd = GetCombatants(plug, pi); lock (cd.Lock) { foreach (dynamic cmx in cd.Combatants) { if (String.Compare(ConvertToHex(cmx.ID), id, true) == 0) { int inParty = 0; try { if ((int)cmx.PartyType == 1) { inParty = 1; } else { inParty = 0; } } catch (Exception) { inParty = 0; } PopulateClumpFromCombatant(vc, cmx, inParty, 0); found = true; break; } } } } catch (Exception ex) { LogMessage(Plugin.DebugLevelEnum.Error, I18n.Translate("internal/ffxiv/idexception", "Exception in FFXIV ID entity retrieve: {0}", ex.Message)); } return(vc); }
public static VariableClump GetNamedEntity(string name) { VariableClump vc = new VariableClump(); try { object plug = null; plug = GetInstance(); if (plug == null) { return(vc); } PropertyInfo pi = GetDataRepository(plug); CombatantData cd = GetCombatants(plug, pi); lock (cd.Lock) { foreach (dynamic cmx in cd.Combatants) { if (cmx.Name == name) { int inParty = 0; try { if ((int)cmx.PartyType == 1) { inParty = 1; } else { inParty = 0; } } catch (Exception) { inParty = 0; } PopulateClumpFromCombatant(vc, cmx, inParty, 0); break; } } } } catch (Exception ex) { LogMessage(Plugin.DebugLevelEnum.Error, I18n.Translate("internal/ffxiv/namedexception", "Exception in FFXIV named entity retrieve: {0}", ex.Message)); } return(vc); }
public static int SortPlayers(VariableClump a, VariableClump b) { int av = cfg.GetPartyOrderValue(a.GetValue("jobid")); int bv = cfg.GetPartyOrderValue(b.GetValue("jobid")); if (av < bv) { //System.Diagnostics.Debug.WriteLine(a.GetValue("name") + " (" + av + ") < " + b.GetValue("name") + " (" + bv + ")"); return(-1); } if (av > bv) { //System.Diagnostics.Debug.WriteLine(a.GetValue("name") + " (" + av + ") > " + b.GetValue("name") + " (" + bv + ")"); return(1); } //System.Diagnostics.Debug.WriteLine(a.GetValue("name") + " (" + av + ") -(" + a.GetValue("name").CompareTo(b.GetValue("name")) + ")- " + b.GetValue("name") + " (" + bv + ")"); return(a.GetValue("name").CompareTo(b.GetValue("name"))); }
public static void PopulateClumpFromCombatant(VariableClump vc, dynamic cmx, int inParty, int inAlliance, int orderNum) { vc.SetValue("name", cmx.Name); vc.SetValue("currenthp", cmx.CurrentHP); vc.SetValue("currentmp", cmx.CurrentMP); vc.SetValue("currentgp", cmx.CurrentGP); vc.SetValue("currentcp", cmx.CurrentCP); vc.SetValue("maxhp", cmx.MaxHP); vc.SetValue("maxmp", cmx.MaxMP); vc.SetValue("maxgp", cmx.MaxGP); vc.SetValue("maxcp", cmx.MaxCP); vc.SetValue("level", cmx.Level); vc.SetValue("jobid", cmx.Job); vc.SetValue("job", TranslateJob(cmx.Job.ToString())); vc.SetValue("role", TranslateRole(cmx.Job.ToString())); vc.SetValue("x", cmx.PosX); vc.SetValue("y", cmx.PosY); vc.SetValue("z", cmx.PosZ); vc.SetValue("id", ConvertToHex(cmx.ID)); vc.SetValue("inparty", inParty); vc.SetValue("inalliance", inAlliance); vc.SetValue("order", orderNum); if (cmx.IsCasting == true) { vc.SetValue("casttargetid", ConvertToHex(cmx.CastTargetID)); } else { vc.SetValue("casttargetid", 0); } if (cmx.TargetID > 0) { vc.SetValue("targetid", ConvertToHex(cmx.TargetID)); } else { vc.SetValue("targetid", 0); } vc.SetValue("heading", cmx.Heading); vc.SetValue("distance", cmx.EffectiveDistance); vc.SetValue("worldid", cmx.WorldID); vc.SetValue("worldname", cmx.WorldName); vc.SetValue("currentworldid", cmx.CurrentWorldID); }
public static int SortPlayers(VariableClump a, VariableClump b) { int av = cfg.GetPartyOrderValue(a.GetValue("jobid")); int bv = cfg.GetPartyOrderValue(b.GetValue("jobid")); if (av < bv) { //System.Diagnostics.Debug.WriteLine(a.GetValue("name") + " (" + av + ") < " + b.GetValue("name") + " (" + bv + ")"); return(-1); } if (av > bv) { //System.Diagnostics.Debug.WriteLine(a.GetValue("name") + " (" + av + ") > " + b.GetValue("name") + " (" + bv + ")"); return(1); } //System.Diagnostics.Debug.WriteLine(a.GetValue("name") + " (" + av + ") -(" + a.GetValue("name").CompareTo(b.GetValue("name")) + ")- " + b.GetValue("name") + " (" + bv + ")"); // https://github.com/paissaheavyindustries/Triggernometry/issues/9 return(b.GetValue("id").CompareTo(a.GetValue("id"))); }
public static void UpdateState() { int phase = 0; try { Int64 old = Interlocked.Read(ref LastCheck); Int64 now = DateTime.Now.Ticks; if (((now - old) / TimeSpan.TicksPerMillisecond) < 1000) { return; } Interlocked.Exchange(ref LastCheck, now); object plug = null; phase = 99; plug = GetInstance(); if (plug == null) { return; } phase = 1; PropertyInfo pi = GetDataRepository(plug); phase = 2; CombatantData cd = GetCombatants(plug, pi); phase = 3; lock (cd.Lock) { int ex = 0; foreach (dynamic cmx in cd.Combatants) { int nump; try { nump = (int)cmx.PartyType; } catch (Exception) { nump = 0; } if (cmx.ID == PlayerId || nump == 1) { if (ex >= PartyMembers.Count) { throw new InvalidOperationException(I18n.Translate("internal/ffxiv/partytoobig", "Party structure has more than {0} members", PartyMembers.Count)); } phase = 4; if (cmx.ID == PlayerId) { Myself = PartyMembers[ex]; } phase = 5; PopulateClumpFromCombatant(PartyMembers[ex], cmx, 1, ex + 1); phase = 6; ex++; if (ex >= PartyMembers.Count) { // full party found break; } } } phase = 7; if (cfg.FfxivPartyOrdering == Configuration.FfxivPartyOrderingEnum.CustomSelfFirst) { //DebugPlayerSorting("a1", PartyMembers); PartyMembers.Sort(SortPlayersSelf); int ro = 1; foreach (VariableClump vc in PartyMembers) { vc.SetValue("order", "" + ro); ro++; } //DebugPlayerSorting("a2", PartyMembers); } else if (cfg.FfxivPartyOrdering == Configuration.FfxivPartyOrderingEnum.CustomFull) { //DebugPlayerSorting("b1", PartyMembers); PartyMembers.Sort(SortPlayers); int ro = 1; foreach (VariableClump vc in PartyMembers) { vc.SetValue("order", "" + ro); ro++; } //DebugPlayerSorting("b2", PartyMembers); } phase = 8; NumPartyMembers = ex; } } catch (Exception ex) { LogMessage(Plugin.DebugLevelEnum.Error, I18n.Translate("internal/ffxiv/updateexception", "Exception in FFXIV state update: {0} at stage {1}", ex.Message, phase)); } }