Jump to content
This site uses cookies! Learn More

This site uses cookies!

By continuing to use this site, you agree to allow us to store cookies on your computer. :)

  • 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

    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.

    Share this comment


    Link to comment
    Share on other sites

    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

    Share this comment


    Link to comment
    Share on other sites
    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")

     

    Share this comment


    Link to comment
    Share on other sites


    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Add a comment...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...