What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

[Plugin]DKP (Archeage raid stats)

Out

Active Member
Joined
Jun 2, 2012
Messages
2,972
Reaction score
13
Plugin to make raid statistics.


1) Start plugin, press "Start" button.
2) Kill raids, etc.
3) Press "Stop" button.
4) Xml file with statistics will appear in DKP plugin folder.
File structure looks like:
PHP:
<RaidInfo>
  <key>09/14/2014 17:33:56</key>
  <realm>B2B-TBC</realm>
  <start>09/14/2014 17:33:56</start>
  <end>09/14/2014 17:36:12</end>
  <zone>Silent Forest</zone>
  <PlayerInfos>
    <key1><name>Player1</name></key1>
    <key2><name>Player2</name></key2>
  </PlayerInfos>
  <BossKills>
    <key1>
      <name>Kraken</name>
      <time>09/18/1320:08:50</time>
      <attendees>
        <key1><name>Player1</name></key1>
        <key2><name>Player2</name></key2>
      </attendees>
    </key1>
  </BossKills>
  <note>Silent Forest</note>
  <Join>
    <key1><player>Player3</player><time>09/18/1319:38:14</time></key1>
    <key2><player>Player4</player><time>09/18/1319:38:14</time></key2>
  </Join>
  <Leave>
    <key1><player>Player3</player><time>09/18/1322:57:26</time></key1>
    <key2><player>Player4</player><time>09/18/1322:57:26</time></key2>
  </Leave>
  <Loot>
    <key1><name>ItemX</name><id>5555</id><count>5</count></key1>
  </Loot>
</RaidInfo>

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;
using System.Text;                 
using System.IO;
using System.Reflection;
using System.Xml;
using System.Threading.Tasks;
using System.Threading;
using ArcheBuddy.Bot.Classes;


namespace YourNamespace
{                      
    public class DkpStat
    {
        private class DkpBossKill
        {
            public string name;
            public DateTime time;
            public List<string> players;
            
            public DkpBossKill(string name, DateTime time, List<string> players)
            {
                this.name = name;
                this.time = time;
                this.players = players;
            }
        }              
        
        private class DkpPlayerJoin
        {
            public DateTime time;
            public string nick;
            public DkpPlayerJoin(string nick, DateTime time)
            {
                this.time = time;
                this.nick = nick;
            }
        }
        
        private class DkpPlayerLeave
        {
            public DateTime time;
            public string nick;
            public DkpPlayerLeave(string nick, DateTime time)
            {
                this.time = time;
                this.nick = nick;
            }
        }
        
        private class DkpLootInfo
        {
            public uint id;
            public string name;
            public int count;
            public DkpLootInfo(uint id, string name, int count)
            {
                this.id = id;
                this.name = name;
                this.count = count;
            }
        }
        private DateTime startTime;
        private DateTime endTime;
        private string realm;
        private string zone;
        private List<string> playerNicks; 
        private List<DkpBossKill> bossKills;
        private List<DkpPlayerJoin> playerJoins;
        private List<DkpPlayerLeave> playerLeaves;
        private string note;
        private List<DkpLootInfo> loots;
        
        public DkpStat()
        {               
            realm = "B2B-TBC";
            startTime = DateTime.Now;
            loots = new List<DkpLootInfo>();   
            playerLeaves = new List<DkpPlayerLeave>();
            playerJoins = new List<DkpPlayerJoin>();    
            bossKills = new List<DkpBossKill>(); 
            playerNicks = new List<string>();
        }        
        
        static private string AssemblyDirectory
        {
            get
            {
                string codeBase = Assembly.GetExecutingAssembly().CodeBase;
                UriBuilder uri = new UriBuilder(codeBase);
                string path = Uri.UnescapeDataString(uri.Path);
                return Path.GetDirectoryName(path);
            }
        }
        
        public void SetZone(string zone)
        {
            this.zone = zone;   
            this.note = zone;
        }
            
        public void PlayerJoin(string nick)
        {
            playerJoins.Add(new DkpPlayerJoin(nick, DateTime.Now));
        }
        
        public void PlayerLeave(string nick)
        {
            playerLeaves.Add(new DkpPlayerLeave(nick, DateTime.Now));
        }          
        
        public void RaidBossDied(string name)
        {                  
            Dictionary<string, bool> temp = new Dictionary<string, bool>();
            int c = 1;
            foreach (var player in playerJoins)
            {               
                if (!temp.ContainsKey(player.nick))
                {
                    temp.Add(player.nick, true); 
                    c++;
                }
            }
            var bossKill = new DkpBossKill(name, DateTime.Now, temp.Keys.ToList());
            bossKills.Add(bossKill);
        }
        
        public void CreateXml()
        {
            endTime = DateTime.Now;
            
            XmlDocument xmlDoc = new XmlDocument();
            XmlNode RaidInfoNode = xmlDoc.CreateElement("RaidInfo");
            xmlDoc.AppendChild(RaidInfoNode);
            
            XmlNode RaidInfoKeyNode = xmlDoc.CreateElement("key");
            RaidInfoKeyNode.InnerText = startTime.ToString("MM'/'dd'/'yyyy HH':'mm':'ss");
            RaidInfoNode.AppendChild(RaidInfoKeyNode);
            
            XmlNode RaidInfoRealmNode = xmlDoc.CreateElement("realm");
            RaidInfoRealmNode.InnerText = realm;
            RaidInfoNode.AppendChild(RaidInfoRealmNode);
            
            XmlNode RaidInfoStartNode = xmlDoc.CreateElement("start");
            RaidInfoStartNode.InnerText = startTime.ToString("MM'/'dd'/'yyyy HH':'mm':'ss");
            RaidInfoNode.AppendChild(RaidInfoStartNode);
            
            XmlNode RaidInfoEndNode = xmlDoc.CreateElement("end");
            RaidInfoEndNode.InnerText = endTime.ToString("MM'/'dd'/'yyyy HH':'mm':'ss");
            RaidInfoNode.AppendChild(RaidInfoEndNode);
            
            XmlNode RaidInfoZoneNode = xmlDoc.CreateElement("zone");
            RaidInfoZoneNode.InnerText = zone;
            RaidInfoNode.AppendChild(RaidInfoZoneNode);                     
            
            XmlNode RaidInfoPlayersNode = xmlDoc.CreateElement("PlayerInfos");
            RaidInfoNode.AppendChild(RaidInfoPlayersNode); 
            Dictionary<string, bool> temp = new Dictionary<string, bool>();
            int c = 1;
            foreach (var player in playerJoins)
            {               
                if (!temp.ContainsKey(player.nick))
                {
                    XmlNode PlayerNode = xmlDoc.CreateElement("key" + c);
                    RaidInfoPlayersNode.AppendChild(PlayerNode); 
                
                    XmlNode PlayerNickNode = xmlDoc.CreateElement("name");
                    PlayerNickNode.InnerText = player.nick;
                    PlayerNode.AppendChild(PlayerNickNode); 
                    
                    temp.Add(player.nick, true); 
                    c++;
                }
            }    
            
            XmlNode RaidInfoBossKillsNode = xmlDoc.CreateElement("BossKills");
            RaidInfoNode.AppendChild(RaidInfoBossKillsNode); 
            for (int i=0;i<bossKills.Count;i++)
            {
                XmlNode KillNode = xmlDoc.CreateElement("key" + (i+1));
                RaidInfoBossKillsNode.AppendChild(KillNode); 
                
                XmlNode KillNameNode = xmlDoc.CreateElement("name");
                KillNameNode.InnerText = bossKills[i].name;
                KillNode.AppendChild(KillNameNode); 
                
                XmlNode KillTimeNode = xmlDoc.CreateElement("time");
                KillTimeNode.InnerText = bossKills[i].time.ToString("MM'/'dd'/'yyyy HH':'mm':'ss");
                KillNode.AppendChild(KillTimeNode); 
                
                XmlNode PlayersNode = xmlDoc.CreateElement("attendees");
                KillNode.AppendChild(PlayersNode); 
                
                for (int j=0;j<bossKills[i].players.Count;j++)
                {
                    XmlNode PlayerKeyNode = xmlDoc.CreateElement("key" + (j+1));
                    PlayersNode.AppendChild(PlayerKeyNode); 
                    
                    XmlNode PlayerNameNode = xmlDoc.CreateElement("player");
                    PlayerNameNode.InnerText = bossKills[i].players[j];
                    PlayerKeyNode.AppendChild(PlayerNameNode); 
                }
            }
            
            XmlNode RaidInfoNoteNode = xmlDoc.CreateElement("note");
            RaidInfoNoteNode.InnerText = note;
            RaidInfoNode.AppendChild(RaidInfoNoteNode); 
            
            XmlNode RaidInfoPlayerJoinsNode = xmlDoc.CreateElement("Join");
            RaidInfoNode.AppendChild(RaidInfoPlayerJoinsNode); 
            for (int i=0;i<playerJoins.Count;i++)
            {
                XmlNode JoinNode = xmlDoc.CreateElement("key" + (i+1));
                RaidInfoPlayerJoinsNode.AppendChild(JoinNode); 
                
                XmlNode JoinNameNode = xmlDoc.CreateElement("player");
                JoinNameNode.InnerText = playerJoins[i].nick;
                JoinNode.AppendChild(JoinNameNode); 
                
                XmlNode JoinTimeNode = xmlDoc.CreateElement("time");
                JoinTimeNode.InnerText = playerJoins[i].time.ToString("MM'/'dd'/'yyyy HH':'mm':'ss");
                JoinNode.AppendChild(JoinTimeNode); 
            }
            
            XmlNode RaidInfoPlayerLeavesNode = xmlDoc.CreateElement("Leave");
            RaidInfoNode.AppendChild(RaidInfoPlayerLeavesNode); 
            for (int i=0;i<playerLeaves.Count;i++)
            {
                XmlNode LeaveNode = xmlDoc.CreateElement("key" + (i+1));
                RaidInfoPlayerLeavesNode.AppendChild(LeaveNode); 
                
                XmlNode LeaveNameNode = xmlDoc.CreateElement("player");
                LeaveNameNode.InnerText = playerLeaves[i].nick;
                LeaveNode.AppendChild(LeaveNameNode); 
                
                XmlNode LeaveTimeNode = xmlDoc.CreateElement("time");
                LeaveTimeNode.InnerText = playerLeaves[i].time.ToString("MM'/'dd'/'yyyy HH':'mm':'ss");
                LeaveNode.AppendChild(LeaveTimeNode); 
            }
            
            XmlNode RaidInfoLootNode = xmlDoc.CreateElement("Loot");
            RaidInfoNode.AppendChild(RaidInfoLootNode); 
            for (int i=0;i<loots.Count;i++)
            {
                XmlNode LootNode = xmlDoc.CreateElement("key" + (i+1));
                RaidInfoLootNode.AppendChild(LootNode); 
                
                XmlNode LootNameNode = xmlDoc.CreateElement("name");
                LootNameNode.InnerText = loots[i].name;
                LootNode.AppendChild(LootNameNode); 
                
                XmlNode LootIdNode = xmlDoc.CreateElement("id");
                LootIdNode.InnerText = loots[i].id.ToString();
                LootNode.AppendChild(LootIdNode); 
                
                XmlNode LootCountNode = xmlDoc.CreateElement("count");
                LootCountNode.InnerText = loots[i].count.ToString();
                LootNode.AppendChild(LootCountNode); 
            }
            xmlDoc.Save(AssemblyDirectory + "\\DKP_" + DateTime.Now.ToString("MM'_'dd'_'yyyy_HH'_'mm'_'ss") + ".xml");
        }
    }
    
    public class YourClass : Core
    {               
        private Form f;   
        private Label label;
        private Button buttonStart, buttonStop;
        private Thread formThread;     
        private DkpStat dkpStat;    
        
        private void InitializeForm()
        {
            f = new Form();
            f.Width = 200;
            f.Height = 120;
            f.Text = "Archeage raid stats";
            f.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            f.MaximizeBox = false;
            f.MinimizeBox = false;
            f.TopMost = true;

            label = new Label();
            label.Left = 8;
            label.Top = 8;
            label.AutoSize = true;
            label.BackColor = Color.Transparent;
            label.Text = "Press start to start write statistics.";
            f.Controls.Add(label);
            label.BringToFront();      
            
            
            buttonStart = new Button();
            buttonStart.Left = 50;
            buttonStart.Top = 35;
            buttonStart.Width = 100;
            buttonStart.Height = 25;
            buttonStart.Text = "Start";
            buttonStart.MouseClick += buttonStartMouseClick;
            f.Controls.Add(buttonStart);
            
            buttonStop = new Button();
            buttonStop.Left = 50;
            buttonStop.Top = 65;
            buttonStop.Width = 100;
            buttonStop.Height = 25;
            buttonStop.Text = "Stop";
            buttonStop.Enabled = false;
            buttonStop.MouseClick += buttonStopMouseClick;
            f.Controls.Add(buttonStop);
        }
        
        private void buttonStopMouseClick(object sender, MouseEventArgs e)
        {
            onNewPartyMember -= NewPartyMember;
            onPartyMemberLeaves -= PartyMemberLeaves;
            onCreatureDied -= CreatureDied;
            dkpStat.CreateXml();
            buttonStart.Enabled = true;
            buttonStop.Enabled = false;  
        }
        
        private void buttonStartMouseClick(object sender, MouseEventArgs e)
        {
            dkpStat = new DkpStat(); 
            dkpStat.SetZone(сurrentTerritoryName());
            foreach (var raidPlayer in me.raid.getMembers())
                dkpStat.PlayerJoin(raidPlayer.nick);
            buttonStart.Enabled = false;
            buttonStop.Enabled = true;
            onNewPartyMember += NewPartyMember;
            onPartyMemberLeaves += PartyMemberLeaves;
            onCreatureDied += CreatureDied;
        }             
        
        private void CreatureDied(Creature obj)
        {
            if (obj != null && obj.type == BotTypes.Npc && obj.db.npcTemplateId == 9 && obj.db.npcGradeId == 3)
            {
                dkpStat.RaidBossDied(obj.name);
            }
        }
        
        private void NewPartyMember(PartyMember member)
        {
            dkpStat.PlayerJoin(member.nick);
        }
        
        private void PartyMemberLeaves(PartyMember member)
        {
            dkpStat.PlayerLeave(member.nick);
        }
        
        private void RunForm()
        {         
            try
            {
                InitializeForm();
                Console.WriteLine("InitializeForm done");
                Application.Run(f);
            }
            catch (Exception error)
            {
                Log(error.ToString());
            }
        }
        
        public void PluginStop()
        {               
            try
            {
                if (f != null)
                {
                    f.Invoke(new Action(() => f.Close()));
                    f.Invoke(new Action(() => f.Dispose()));
                }
                if (formThread.ThreadState == System.Threading.ThreadState.Running)
                {
                    formThread.Abort();
                    formThread.Join();
                }
            }
            catch (Exception error)
            {
                Log(error.ToString());
            }
        }
        
        public void MyEventTest(DoodadObject coffer)
        {
            Console.WriteLine(coffer.name);
        }
        
        public void PluginRun()
        {          
            formThread = new Thread(RunForm);
            formThread.SetApartmentState(ApartmentState.STA);
            formThread.Start();
            while (true)
                Thread.Sleep(100);
        }
    }
}
 
Can we get something useful like an aio class? Perhaps anything that is listed on the purchase page? PVP/PVE support would be fantastic.
 
Awesome! Nice job Out!
It would be nice if we add some DPS per Player and the looting information.
 
It would be nice if we add some DPS per Player and the looting information.
DPS hard to calculate, but i can try.
Looting (drop from Raid) already included
 
Out i am trying to get DPS too for a simple bar showing it and a way to evaluate combos to TRY to auto-build rotations (or at least help to make one).

All i found was target.hpp before casting the skill and after, the problem is that at least 50% of the time it returns the same value before and after the cast.
Also obviously if you are not the only one hitting the target it will screw the calculation up.

The other thing i thought was to make a chat channel that shows only the skill damage and read that channel maybe ?

The client gets sent that info from the server, as it is displayed on screen and in the chat if you configure it. but haven't found where (or IF) AB gets that info.

Hope this helps in any way.
 
All i found was target.hpp before casting the skill and after, the problem is that at least 50% of the time it returns the same value before and after the cast.
Hi.
onUnitDamaged && onUnitHealed events can help you.
 
Back
Top