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

Detecting the cast of Town Portal

TarasBulba

Community Developer
Joined
Apr 27, 2015
Messages
794
Reaction score
25
Is there any way to detect if the player (not the bot) is casting town portal from a plugin, something like ZetaDia.Me.CastingTownPortal?

Edit: Actually, it would be better to be able to detect if the player has an active cast bar on him.
 
Last edited:
I think I found the answer, at least for the portal.

Code:
(int)ZetaDia.Me.CommonData.AnimationState == 13
 
Could also do this

Code:
        public static async Task<bool> WaitForCast()
        {
            return await Coroutine.Wait(500, () =>  ZetaDia.Me.CommonData.AnimationState == AnimationState.Casting);
        }
 
Could also do this

Code:
        public static async Task<bool> WaitForCast()
        {
            return await Coroutine.Wait(500, () =>  ZetaDia.Me.CommonData.AnimationState == AnimationState.Casting);
        }

Thank you :)
 
As I found, ZetaDia.Me.CommonData.AnimationState returns states
  • casting channeled spells, player resurection and item identification (7)
  • casting town portal (3)
  • loading screen(13)

Is possible to refer to casting/resurection/item identification states separately?
 
We recently worked out how to check if player is casting by spell. in case this helps anyone. Need to check for snopower.

(this hasnt been fully tested, may not work entirely but the idea is sound).


Code:
            public bool IsCastingTownPortalOrTeleport()
            {
                try
                {
                    var commonData = ZetaDia.Me.CommonData;        
                                                   
                    if (CheckVisualEffectNoneForPower(commonData, SNOPower.UseStoneOfRecall))
                    {
                        Logger.LogVerbose("Player is casting 'UseStoneOfRecall'");
                        return true;
                    }


                    if (CheckVisualEffectNoneForPower(commonData, SNOPower.TeleportToPlayer_Cast))
                    {
                        Logger.LogVerbose("Player is casting 'TeleportToPlayer_Cast'");
                        return true;
                    }
                        
                    if (CheckVisualEffectNoneForPower(commonData, SNOPower.TeleportToWaypoint_Cast))
                  {
                        Logger.LogVerbose("Player is casting 'TeleportToWaypoint_Cast'");
                        return true;
                    }


                    return false;
                }
                catch (Exception) { }
                return false;
            }


            private static bool CheckVisualEffectNoneForPower(ACD commonData, SNOPower power)
            {
                if (commonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff0VisualEffectNone & 0xFFF)) == 1)
                    return true;
                if (commonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff1VisualEffectNone & 0xFFF)) == 1)
                    return true;
                if (commonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff2VisualEffectNone & 0xFFF)) == 1)
                    return true;
                if (commonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff3VisualEffectNone & 0xFFF)) == 1)
                    return true;
                if (commonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff4VisualEffectNone & 0xFFF)) == 1)
                    return true;
                if (commonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff5VisualEffectNone & 0xFFF)) == 1)
                    return true;


                return false;
            }
 
Back
Top