public void Update(bool combat = false, bool force = false)
{
double lastUpdate = DateTime.Now.Subtract(lastUpdatedPlayer).TotalMilliseconds;
//Update only every 100ms, unless in combat than 25ms..
if (!force &&
(combat && lastUpdate < 50 || lastUpdate < 150)) return;
using (ZetaDia.Memory.AcquireFrame())
{
try
{
// If we aren't in the game of a world is loading, don't do anything yet
if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid || ZetaDia.IsLoadingWorld) return;
var me = ZetaDia.Me;
if (me == null) return;
//update actorSNO
if (ActorSno == -1)
{
ActorSno = me.ActorSNO;
}
if (FunkyGame.CurrentActorClass == ActorClass.DemonHunter)
{
dDiscipline = me.CurrentSecondaryResource;
if (dDiscipline > MaxDiscipline) MaxDiscipline = dDiscipline;
dDisciplinePct = dDiscipline / MaxDiscipline;
}
double curhealthpct = me.HitpointsCurrentPct;
if (!dcurrentHealthPct.Equals(curhealthpct))
healthvalueChanged(dcurrentHealthPct, curhealthpct);
dCurrentEnergy = me.CurrentPrimaryResource;
if (dCurrentEnergy > MaxEnergy) MaxEnergy = dCurrentEnergy;
dCurrentEnergyPct = dCurrentEnergy / MaxEnergy;
bIsInBossEncounter = me.IsInBossEncounter;
bIsInTown = ZetaDia.IsInTown;
bIsRooted = me.IsRooted || Hotbar.HasDebuff(SNOPower.MonsterAffix_JailerCast);
var frozen = me.IsFrozen || Hotbar.HasDebuff(SNOPower.CritDebuffCold);
var feared = me.IsFeared || Hotbar.HasDebuff(SNOPower.DebuffFeared);
if (feared || me.IsStunned || frozen || me.IsBlind)
bIsIncapacitated = true;
else
{
var bIsInKnockBack = (me.CommonData.GetAttribute<int>(ActorAttributeType.InKnockback) != 0);
bIsIncapacitated = bIsInKnockBack; //|| FunkyGame.Hero.Class.KnockbackLandAnims.Contains(CurrentSNOAnim);
}
int currentLevelAreaID = ZetaDia.CurrentLevelAreaId;
int currentWorldID = ZetaDia.CurrentWorldId;
bool inRift = TheCache.riftWorldIds.Contains(currentWorldID);
if (iCurrentLevelID != currentLevelAreaID || (inRift && currentWorldID != CurrentWorldID))
{
CurrentWorldDynamicID = ZetaDia.CurrentWorldDynamicId;
CurrentWorldID = ZetaDia.CurrentWorldId;
levelareaIDchanged(currentLevelAreaID);
}
if (FunkyGame.CurrentHeroLevel == 70)
CurrentExp = me.ParagonCurrentExperience;
else
CurrentExp = me.CurrentExperience;
//Set Character Radius?
if (fCharacterRadius == 0f)
{
fCharacterRadius = me.ActorInfo.Sphere.Radius;
//Wizards are short -- causing issues (At least Male Wizard is!)
//if (Bot.Game.ActorClass == ActorClass.Wizard) this.fCharacterRadius += 1f;
}
//Update vars that are not essential to combat (survival).
if (DateTime.Now.Subtract(lastUpdateNonEssentialData).TotalSeconds > 30)
{
lastUpdateNonEssentialData = DateTime.Now;
//update level if not 60 else update paragonlevel
if (iMyLevel < 70) iMyLevel = me.Level;
iMyDynamicID = me.CommonData.DynamicId;
FreeBackpackSlots = me.Inventory.NumFreeBackpackSlots;
PickupRadius = me.GoldPickupRadius;
Coinage = ZetaDia.CPlayer.Coinage;
}
if (UpdateCoinage)
Coinage = ZetaDia.CPlayer.Coinage;
//Check current scence every 1.5 seconds
if (!bIsInTown && DateTime.Now.Subtract(lastCheckedSceneID).TotalSeconds > 1.50)
{
//Get the current guid, compare/update.
int CurrentSceneID = me.CurrentScene.SceneGuid;
if (CurrentSceneID != iSceneID)
{
iSceneID = CurrentSceneID;
SceneName = me.CurrentScene.Name;
}
lastCheckedSceneID = DateTime.Now;
}
}
catch (Exception)
{
}
}
lastUpdatedPlayer = DateTime.Now;
}