stun

Discuss the development of Lua addons for Ashita here.
Locked
gilles
Posts: 28
Joined: Sun May 15, 2016 1:53 pm

stun

Post by gilles » Fri Oct 14, 2016 2:35 am

i use an external tool which read chatlog to automate stun (violent flourish)
stun command is sent with elite

sometimes, stun is not executed

maybe i have issue with this third party tool so i made a small addon

V1 :

Code: Select all

_addon.author   = 'Moi';
_addon.name     = 'moistun';
_addon.version  = '1.0';

require 'common'

---------------------------------------------------------------------------------------------------
-- func: newchat
-- desc: Called when a new line is incoming in chatlog.
---------------------------------------------------------------------------------------------------
ashita.register_event('newchat', function(mode, chat)

  line = chat:lower();

  -- remove ashita timestamp if they exist
  if (line:sub( 3, 3 ) == '[' and line:sub( 12, 12 ) == ']') then
    line = chat:lower():sub( 16, 500 );
  end

  a = string.find(line, 'mnyiri');
  b = string.find(line, 'readies');
  c = string.find(line, 'bewitching lantern');
  d = string.find(line, 'hypnic lamp');
  if (a ~= nil) then
    if (b ~= nil) then
      if (c ~= nil) then
        print('stun');
        AshitaCore:GetChatManager():ParseCommand('/ja "violent flourish" <t>', 1);
      end
      if (d ~= nil) then
        print('stun');
        AshitaCore:GetChatManager():ParseCommand('/ja "violent flourish" <t>', 1);
      end
    end
  end

end );
unfortunately, i got the same bug : sometimes command is not executed
i got the "stun" message from print command
i think it's the ParseCommand which sometimes is not executed

i made a V2 with a different strategy
V2 is going to spam ParseCommand for 7s
this way, if the first ParseCommand fail, the 2nd or third or others will be executed

V2 :

Code: Select all

_addon.author   = 'Moi';
_addon.name     = 'moistun';
_addon.version  = '1.0';

require 'common'

local stun = 0;

---------------------------------------------------------------------------------------------------
-- func: Render
-- desc: Called when our addon is rendered.
---------------------------------------------------------------------------------------------------
ashita.register_event('render', function()
  if ( stun == 1 ) then
    if ( os.time() < stun_date +7 ) then
      AshitaCore:GetChatManager():ParseCommand('/ja "violent flourish" <t>', 1);
    else
      stun = 0;
      print("stun end");
    end
  end
end );

---------------------------------------------------------------------------------------------------
-- func: newchat
-- desc: Called when a new line is incoming in chatlog.
---------------------------------------------------------------------------------------------------
ashita.register_event('newchat', function(mode, chat)

  line = chat:lower();

  -- remove ashita timestamp if they exist
  if (line:sub( 3, 3 ) == '[' and line:sub( 12, 12 ) == ']') then
    line = chat:lower():sub( 16, 500 );
  end

--print('::'..line);


      a = string.find(line, 'mnyiri');
      b = string.find(line, 'readies');
      c = string.find(line, 'bewitching lantern');
      d = string.find(line, 'hypnic lamp');
      if (a ~= nil) then
        if (b ~= nil) then
          if (c ~= nil) then
            print('stun start');
            stun_date = os.time();
            stun = 1;
          end
          if (d ~= nil) then
            print('stun start');
            stun_date = os.time();
            stun = 1;
          end
        end
      end


end );
but i got the same problem
i got the 'stun start' and 'stun end' message but sometimes, clearly, none of the commands are executed
9 times on 10, i know commands are executed because i got message error relative to recast ability in chatlog
unfortunately, 1 time on 10, none of the commands are executed

am i doing something wrong ?
gilles
Posts: 28
Joined: Sun May 15, 2016 1:53 pm

Re: stun

Post by gilles » Fri Oct 14, 2016 11:38 am

could it be that, if i'm in an animation, commands are delayed ?

i'm going to do more tests to see if this happens when i'm just on auto-attack (no WS, no healing waltz)
User avatar
atom0s
Site Admin
Posts: 373
Joined: Sat May 14, 2016 5:13 pm

Re: stun

Post by atom0s » Sat Oct 15, 2016 10:18 am

Addons should use QueueCommand instead of ParseCommand due to threading issues.
Lead Ashita Developer

Want to donate to say thanks?
https://www.paypal.me/atom0s
gilles
Posts: 28
Joined: Sun May 15, 2016 1:53 pm

Re: stun

Post by gilles » Sun Oct 16, 2016 9:51 am

OK, i'm going to try that
Locked