Ejemplo n.º 1
0
 private float GetMaxSecondaryResource(DiaActivePlayer player)
 {
     switch (ActorClass)
     {
     case ActorClass.DemonHunter:
         return(ZetaDia.Me.CommonData.GetAttribute <float>(149 | (int)ResourceType.Discipline << 12) + player.CommonData.GetAttribute <float>(ActorAttributeType.ResourceMaxBonusDiscipline));
     }
     return(-1);
 }
Ejemplo n.º 2
0
        //private float GetMaxPrimaryResource(DiaActivePlayer player)
        //{
        //    return player.MaxPrimaryResource;
        //}

        private float GetMaxPrimaryResource(DiaActivePlayer player)
        {
            switch (ActorClass)
            {
            case ActorClass.Wizard:
                return(player.CommonData.GetAttribute <float>(149 | (int)ResourceType.Arcanum << 12) + player.CommonData.GetAttribute <float>(ActorAttributeType.ResourceEffectiveMaxArcanum));

            case ActorClass.Barbarian:
                return(player.MaxPrimaryResource);

            case ActorClass.Monk:
                return(player.CommonData.GetAttribute <float>(149 | (int)ResourceType.Spirit << 12) + player.CommonData.GetAttribute <float>(ActorAttributeType.ResourceMaxBonusSpirit));

            case ActorClass.Crusader:
                return(player.CommonData.GetAttribute <float>(149 | (int)ResourceType.Faith << 12) + player.CommonData.GetAttribute <float>(ActorAttributeType.ResourceMaxBonusFaith));

            case ActorClass.DemonHunter:
                return(player.CommonData.GetAttribute <float>(149 | (int)ResourceType.Hatred << 12) + player.CommonData.GetAttribute <float>(ActorAttributeType.ResourceMaxBonusHatred));

            case ActorClass.Witchdoctor:
                return(player.CommonData.GetAttribute <float>(149 | (int)ResourceType.Mana << 12) + player.CommonData.GetAttribute <float>(ActorAttributeType.ResourceMaxBonusMana));
            }
            return(-1);
        }
Ejemplo n.º 3
0
        internal void Update()
        {
            using (new PerformanceLogger("UpdateCachedPlayerData"))
            {
                if (DateTime.UtcNow.Subtract(LastUpdated).TotalMilliseconds <= 25)
                {
                    return;
                }

                if (!ZetaDia.IsInGame)
                {
                    IsInGame = false;
                    IsValid  = false;
                    return;
                }

                if (ZetaDia.Globals.IsLoadingWorld)
                {
                    IsLoadingWorld = true;
                    IsValid        = false;
                    return;
                }

                _me = ZetaDia.Me;
                if (_me == null || !_me.IsFullyValid())
                {
                    IsValid = false;
                    return;
                }

                try
                {
                    var levelAreaId = ZetaDia.CurrentLevelAreaSnoId;
                    if (levelAreaId != LevelAreaId)
                    {
                        LastChangedLevelAreaId = DateTime.UtcNow;
                        LevelAreaId            = levelAreaId;
                    }

                    IsValid        = true;
                    IsInGame       = true;
                    IsLoadingWorld = false;


                    WorldDynamicId = ZetaDia.Globals.WorldId;
                    WorldSnoId     = ZetaDia.Globals.WorldSnoId;

                    if (DateTime.UtcNow.Subtract(LastVerySlowUpdate).TotalMilliseconds > 5000)
                    {
                        UpdateVerySlowChangingData();
                    }

                    if (DateTime.UtcNow.Subtract(LastSlowUpdate).TotalMilliseconds > 1000)
                    {
                        UpdateSlowChangingData();
                    }

                    UpdateFastChangingData();
                }
                catch (Exception ex)
                {
                    Core.Logger.Debug(LogCategory.CacheManagement, "Safely handled exception for grabbing player data.{0}{1}", Environment.NewLine, ex);
                }
            }
        }
Ejemplo n.º 4
0
        private void btnRefreshCharacter_Click(object sender, EventArgs e)
        {
            if (BotMain.IsRunning)
            {
                return;
            }

            panelCharacterStats.Controls.Clear();
            panelCharacterInventory.Controls.Clear();
            panelCharacterEquipped.Controls.Clear();

            try
            {
                using (ZetaDia.Memory.SaveCacheState())
                {
                    ZetaDia.Memory.DisableCache();

                    double iType = -1;

                    ZetaDia.Actors.Update();

                    DiaActivePlayer me = ZetaDia.Me;
                    foreach (var buff in me.GetAllBuffs())
                    {
                        try
                        {
                            Label entry = new Label
                            {
                                AutoEllipsis = true,
                                AutoSize     = true,
                                Dock         = DockStyle.Top,
                                BorderStyle  = BorderStyle.FixedSingle,
                            };
                            entry.DoubleClick += entryDoubleClick;
                            entry.Text         = String.Format("Buff: {0} SNOID: {1} StackCount: {2} IsCancelable: {3}",
                                                               buff.InternalName, buff.SNOId, buff.StackCount, buff.IsCancelable);
                            panelCharacterStats.Controls.Add(entry);
                        }
                        catch (Exception)
                        {
                        }
                    }
                    foreach (var buff in me.GetAllDebuffs())
                    {
                        try
                        {
                            Label entry = new Label
                            {
                                AutoEllipsis = true,
                                AutoSize     = true,
                                Dock         = DockStyle.Top,
                                BorderStyle  = BorderStyle.FixedSingle,
                            };
                            entry.DoubleClick += entryDoubleClick;
                            entry.Text         = String.Format("Debuff: {0} SNOID: {1} StackCount: {2} IsCancelable: {3}",
                                                               buff.InternalName, buff.SNOId, buff.StackCount, buff.IsCancelable);
                            panelCharacterStats.Controls.Add(entry);
                        }
                        catch (Exception)
                        {
                        }
                    }

                    Label[] entrySkills = new Label[5];
                    entrySkills[0] = new Label
                    {
                        AutoEllipsis = true,
                        AutoSize     = true,
                        Dock         = DockStyle.Top,
                        BorderStyle  = BorderStyle.FixedSingle,
                        Text         = ReturnSkillString(HotbarSlot.HotbarMouseLeft)
                    };
                    entrySkills[0].DoubleClick += entryDoubleClick;
                    panelCharacterStats.Controls.Add(entrySkills[0]);

                    entrySkills[1] = new Label
                    {
                        AutoEllipsis = true,
                        AutoSize     = true,
                        Dock         = DockStyle.Top,
                        BorderStyle  = BorderStyle.FixedSingle,
                        Text         = ReturnSkillString(HotbarSlot.HotbarMouseRight)
                    };
                    entrySkills[1].DoubleClick += entryDoubleClick;
                    panelCharacterStats.Controls.Add(entrySkills[1]);

                    entrySkills[2] = new Label
                    {
                        AutoEllipsis = true,
                        AutoSize     = true,
                        Dock         = DockStyle.Top,
                        BorderStyle  = BorderStyle.FixedSingle,
                        Text         = ReturnSkillString(HotbarSlot.HotbarSlot1)
                    };
                    entrySkills[2].DoubleClick += entryDoubleClick;
                    panelCharacterStats.Controls.Add(entrySkills[2]);

                    entrySkills[3] = new Label
                    {
                        AutoEllipsis = true,
                        AutoSize     = true,
                        Dock         = DockStyle.Top,
                        BorderStyle  = BorderStyle.FixedSingle,
                        Text         = ReturnSkillString(HotbarSlot.HotbarSlot2)
                    };
                    entrySkills[3].DoubleClick += entryDoubleClick;
                    panelCharacterStats.Controls.Add(entrySkills[3]);

                    entrySkills[4] = new Label
                    {
                        AutoEllipsis = true,
                        AutoSize     = true,
                        Dock         = DockStyle.Top,
                        BorderStyle  = BorderStyle.FixedSingle,
                        Text         = ReturnSkillString(HotbarSlot.HotbarSlot3)
                    };
                    entrySkills[4].DoubleClick += entryDoubleClick;
                    panelCharacterStats.Controls.Add(entrySkills[4]);

                    entrySkills[5] = new Label
                    {
                        AutoEllipsis = true,
                        AutoSize     = true,
                        Dock         = DockStyle.Top,
                        BorderStyle  = BorderStyle.FixedSingle,
                        Text         = ReturnSkillString(HotbarSlot.HotbarSlot4)
                    };
                    entrySkills[5].DoubleClick += entryDoubleClick;
                    panelCharacterStats.Controls.Add(entrySkills[5]);

                    //entry.DoubleClick += entryDoubleClick;
                    //entry.Text = String.Format("Skill: {0}", skill);
                    //panelCharacterStats.Controls.Add(entry);

                    //String.Format("Armor: {0} ArmorBonusItem: {1} ArmorItemTotal: {2} ArmorItemSubTotal: {3}" +
                    //			  "AttacksPerSecond: {4} AttacksPerSecondBase: {5}",
                    //				me.Armor, me.ArmorBonusItem, me.ArmorItemTotal, me.ArmorItemSubTotal,
                    //				me.AttacksPerSecond,me.AttacksPerSecondBase);
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 5
0
 private float GetMaxSecondaryResource(DiaActivePlayer player)
 {
     switch (ActorClass)
     {
         case ActorClass.DemonHunter:
             return ZetaDia.Me.CommonData.GetAttribute<float>(149 | (int)ResourceType.Discipline << 12) + player.CommonData.GetAttribute<float>(ActorAttributeType.ResourceMaxBonusDiscipline);
     }
     return -1;
 }
Ejemplo n.º 6
0
 private float GetMaxPrimaryResource(DiaActivePlayer player)
 {
     switch (ActorClass)
     {
         case ActorClass.Wizard:
             return ZetaDia.Me.CommonData.GetAttribute<float>(149 | (int)ResourceType.Arcanum << 12) + player.CommonData.GetAttribute<float>(ActorAttributeType.ResourceMaxBonusArcanePower);
         case ActorClass.Barbarian:
             return ZetaDia.Me.CommonData.GetAttribute<float>(149 | (int)ResourceType.Fury << 12) + player.CommonData.GetAttribute<float>(ActorAttributeType.ResourceMaxBonusFury);
         case ActorClass.Monk:
             return ZetaDia.Me.CommonData.GetAttribute<float>(149 | (int)ResourceType.Spirit << 12) + player.CommonData.GetAttribute<float>(ActorAttributeType.ResourceMaxBonusSpirit);
         case ActorClass.Crusader:
             return ZetaDia.Me.CommonData.GetAttribute<float>(149 | (int)ResourceType.Faith << 12) + player.CommonData.GetAttribute<float>(ActorAttributeType.ResourceMaxBonusFaith);
         case ActorClass.DemonHunter:
             return ZetaDia.Me.CommonData.GetAttribute<float>(149 | (int)ResourceType.Hatred << 12) + player.CommonData.GetAttribute<float>(ActorAttributeType.ResourceMaxBonusHatred);
         case ActorClass.Witchdoctor:
             return ZetaDia.Me.CommonData.GetAttribute<float>(149 | (int)ResourceType.Mana << 12) + player.CommonData.GetAttribute<float>(ActorAttributeType.ResourceMaxBonusMana);
     }
     return -1;
 }
Ejemplo n.º 7
0
			internal void UpdatePlayerCache()
			{               
				using (new PerformanceLogger("UpdateCachedPlayerData"))
				{
					if (DateTime.UtcNow.Subtract(LastUpdated).TotalMilliseconds <= 100)
						return;

					if (!ZetaDia.IsInGame)
					{
                        IsInGame = false;
                        IsValid = false;
						return;
					}

					if (ZetaDia.IsLoadingWorld)
					{
                        IsLoadingWorld = true;
                        IsValid = false;
						return;
					}
                    
					_me = ZetaDia.Me;
					if (_me == null || !_me.IsFullyValid())
					{
                        IsValid = false;
						return;
					}

					try
					{
                        IsValid = true;
                        IsInGame = true;
                        IsLoadingWorld = false;

                        LevelAreaId = ZetaDia.CurrentLevelAreaId;
                        WorldDynamicID = ZetaDia.CurrentWorldDynamicId;
                        WorldID = ZetaDia.CurrentWorldId;

                        Trinity.CurrentWorldDynamicId = WorldDynamicID;
                        Trinity.CurrentWorldId = WorldID;

						if (DateTime.UtcNow.Subtract(LastVerySlowUpdate).TotalMilliseconds > 5000)
							UpdateVerySlowChangingData();

					    if (DateTime.UtcNow.Subtract(LastSlowUpdate).TotalMilliseconds > 1000)					   
                            UpdateSlowChangingData();								                  

                        UpdateFastChangingData();

					}
					catch (Exception ex)
					{
						Logger.Log(TrinityLogLevel.Debug, LogCategory.CacheManagement, "Safely handled exception for grabbing player data.{0}{1}", Environment.NewLine, ex);
					}
				}
			}
Ejemplo n.º 8
0
        private void btnRefreshCharacter_Click(object sender, EventArgs e)
        {
            if (BotMain.IsRunning)
            {
                return;
            }

            flowLayout_OutPut.Controls.Clear();

            try
            {
                using (ZetaDia.Memory.SaveCacheState())
                {
                    ZetaDia.Memory.DisableCache();
                    ZetaDia.Actors.Update();

                    DiaActivePlayer me = ZetaDia.Me;
                    foreach (var buff in me.GetAllBuffs())
                    {
                        try
                        {
                            flowLayout_OutPut.Controls.Add(new UserControlDebugEntry(String.Format("Buff: {0} SNOID: {1} StackCount: {2} IsCancelable: {3}",
                                                                                                   buff.InternalName, buff.SNOId, buff.StackCount, buff.IsCancelable)));
                        }
                        catch (Exception)
                        {
                        }
                    }
                    foreach (var buff in me.GetAllDebuffs())
                    {
                        try
                        {
                            flowLayout_OutPut.Controls.Add(new UserControlDebugEntry(String.Format("Debuff: {0} SNOID: {1} StackCount: {2} IsCancelable: {3}",
                                                                                                   buff.InternalName, buff.SNOId, buff.StackCount, buff.IsCancelable)));
                        }
                        catch (Exception)
                        {
                        }
                    }

                    var hotbarslots = Enum.GetValues(typeof(HotbarSlot));
                    foreach (HotbarSlot hotbarslot in hotbarslots)
                    {
                        if (hotbarslot == HotbarSlot.Invalid)
                        {
                            continue;
                        }
                        flowLayout_OutPut.Controls.Add(new UserControlDebugEntry(ReturnSkillString(hotbarslot)));
                    }

                    try
                    {
                        SNOPower power = SNOPower.DrinkHealthPotion;
                        PowerManager.CanCastFlags castflags;
                        bool   cancast      = Zeta.Bot.PowerManager.CanCast(power, out castflags);
                        string potionString = String.Format("Skill: {0} HotbarSlot: {1} RuneIndex: {2}\r\n" +
                                                            "CanCast: {3} CanCastFlags: {4}",
                                                            power, HotbarSlot.Invalid, -1, cancast, castflags);
                        flowLayout_OutPut.Controls.Add(new UserControlDebugEntry(potionString));
                    }
                    catch (Exception)
                    {
                    }

                    foreach (var snoPower in ZetaDia.CPlayer.PassiveSkills)
                    {
                        string s = String.Format("Passive Skill {0}", snoPower.ToString());
                        flowLayout_OutPut.Controls.Add(new UserControlDebugEntry(s));
                    }
                }
            }
            catch (Exception ex)
            {
            }

            flowLayout_OutPut.Focus();
        }