Jump to content
  • EventsLuaWithArgs.OnEventsLuaWithArgs not firing some events


    Matenia
    • Version: All Product: WRobot General Type: Bug Status: Not a Bug

    Hey @Droidz

    I tested on 1.12:

    EventsLuaWithArgs.OnEventsLuaWithArgs += CastingEventHandler;
    private void CastingEventHandler(LuaEventsId id, List<string> args)
        {
            if (id == LuaEventsId.SPELLCAST_STOP)
            {
                _LastSpell = args[1];
                _LastCastTimeStamp = DateTime.Now.AddMilliseconds(double.Parse(args[0]));
                if (_LastSpell == "Polymorph")
                {
                    _LastPoly = DateTime.Now.AddMilliseconds(double.Parse(args[0]));
                }
                Logging.WriteDebug("Last cast spell " + args[1] + " with cast time: " + args[0]);
            }
            if(id == LuaEventsId.SPELLCAST_DELAYED)
            {
                _LastCastTimeStamp = _LastCastTimeStamp.AddMilliseconds(double.Parse(args[0]));
                if(_LastSpell == "Polymorph")
                {
                    _LastPoly = _LastPoly.AddMilliseconds(double.Parse(args[0]));
                }
            }
        }

    but my code is never even called.
    I think the handler just doesn't receive info on those events in wRobot vanilla.



    User Feedback

    Recommended Comments

    Matenia

    Posted

    3ImTerm.png

    For the following code:

    class AntiDrown
    {
        private static DateTime BreathExpires = DateTime.MaxValue;
    
        public static void Start()
        {
            EventsLuaWithArgs.OnEventsLuaWithArgs += AntiDrownEventHandler;
        }
    
        public static void Stop()
        {
            EventsLuaWithArgs.OnEventsLuaWithArgs -= AntiDrownEventHandler;
        }
    
        private static void AntiDrownEventHandler(LuaEventsId id, List<string> args)
        {
            
            if (id == LuaEventsId.MIRROR_TIMER_START)
            {
                Logging.WriteDebug(args[0] + "  " + args[1]);
            }
            if (id == LuaEventsId.MIRROR_TIMER_START && args[0] == "BREATH")
            {
                //sets BreathExpires to be in the future by x milliseconds
                BreathExpires = DateTime.Now.AddMilliseconds(double.Parse(args[1]));
                Logging.WriteDebug("Breath has " + double.Parse(args[1]) + " milliseconds left");
            }
        }
    
        public static void DontDrown()
        {
            //check if we drown in less than 5 seconds
            while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && DateTime.Now.AddSeconds(5) > BreathExpires)
            {
                Move.JumpOrAscend();
                Thread.Sleep(500);
            }
        }
    }

    I call Start and Stop methos from plugin.

    Matenia

    Posted (edited)

    Maybe the problem is that I reference TBC libraries of wRobot? I compile 1 dll for vanilla + tbc. 
    It shouldn't really change anything, but maybe it does? I thought events remained the same
    Maybe same problem as here:

    I use TBC LuaEventsId.PLAYER_DEAD and it's different in different expacs.

    Edited by Matenia
    Droidz

    Posted

    54 minutes ago, Matenia said:

    Maybe the problem is that I reference TBC libraries of wRobot? I compile 1 dll for vanilla + tbc. 
    It shouldn't really change anything, but maybe it does? I thought events remained the same
    Maybe same problem as here:

    I use TBC LuaEventsId.PLAYER_DEAD and it's different in different expacs.

    It is that I think, Event id change frequently, and when you compile DLL, compiler put id in dll (not the enum name).

    To fix it, try to (by sample) replace:

    if (id == LuaEventsId.MIRROR_TIMER_START)

    by

    if (id.ToString() == "MIRROR_TIMER_START")

     



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...