Page 2 of 2 FirstFirst 1 2
Results 11 to 13 of 13

Thread: Query client language?

  1. #11
    Basic Member
    Join Date
    Mar 2012
    Posts
    2,017
    Quote Originally Posted by seanjoeut View Post
    But could you maybe give me a pointer how to? Is there a function that does that or do I need to take a course?
    I can. But it depends how well you know Lua. Trust me when I say this: blindly copy pasting random code from random sources that does something, then massacring it to do what you want in a very crude manner without understanding what you do won't end well
    If you don't know Lua, learn it first. It's complex, but not complicated. You should be done in around 1 month for the basics and in around 2 months you should be ready to try something a bit more complex like a SBM. There are no shortcuts. You don't read a 2-day tutorial then just magically "know" how to do it in Lua. Just like you can't become a millionaire, lose weight, get every supermodel girl or get muscles over night. It takes work and dedication and most of all: patience. Mistakes will come which should not make you give up. I saw some posts from guys without experience in scripting or programming that got excited when the API was out but quickly went away when they realized that the API doesn't do everything for them and actual research and code design is involved.

    So if you have some scripting (programming is ideal, but scripting should be enough to get you started) background it will obviously be faster and easier
    Let's start with a simple question: do you know what callbacks are and how they work? (no, I don't mean you go on google and copy paste a definition from a random site and write it here, I am asking if you know what they are and how they work - at least on a high level basis). If not, first try to learn Lua and make the bot do some basic stuff, then you can worry about reading chat IMO

    Here is a small discussion on the topic. It has a bunch of PoCs (proofs of concept) but you need to modify them to make them to get them into an actual botpack. PoCs are, afterall, experiments and should not end up in the final code you use in the game
    Last edited by The Nomad; 10-22-2017 at 10:27 PM.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  2. #12
    Basic Member
    Join Date
    Dec 2016
    Posts
    10
    Quote Originally Posted by The Nomad View Post
    I can. But it depends how well you know Lua. Trust me when I say this: blindly copy pasting random code from random sources that does something, then massacring it to do what you want in a very crude manner without understanding what you do won't end well
    If you don't know Lua, learn it first. It's complex, but not complicated. You should be done in around 1 month for the basics and in around 2 months you should be ready to try something a bit more complex like a SBM. There are no shortcuts. You don't read a 2-day tutorial then just magically "know" how to do it in Lua. Just like you can't become a millionaire, lose weight, get every supermodel girl or get muscles over night. It takes work and dedication and most of all: patience. Mistakes will come which should not make you give up. I saw some posts from guys without experience in scripting or programming that got excited when the API was out but quickly went away when they realized that the API doesn't do everything for them and actual research and code design is involved.

    So if you have some scripting (programming is ideal, but scripting should be enough to get you started) background it will obviously be faster and easier
    Let's start with a simple question: do you know what callbacks are and how they work? (no, I don't mean you go on google and copy paste a definition from a random site and write it here, I am asking if you know what they are and how they work - at least on a high level basis). If not, first try to learn Lua and make the bot do some basic stuff, then you can worry about reading chat IMO

    Here is a small discussion on the topic. It has a bunch of PoCs (proofs of concept) but you need to modify them to make them to get them into an actual botpack. PoCs are, afterall, experiments and should not end up in the final code you use in the game
    Thank you so much for the detailed answer!! I have some experience in Python, Matlab, and a little bit Cpp. (Never really programmed, only researched algorithms so they are all scripting to me XD) So far I've only changed 5 heroes their ability usage and item purchase, just to see how things work. And they are already wrecking default bots! which gave me a lot of incentive to learn Lua just to play with this

    I haven't used any feature that seems Lua specific, just basic logics and tables. I don't know callbacks at all, I can only guess from name that it's some event outside of your script that calls the function you passed in? Anyways guess I should be doing some readings and experiments while I make my bot a bit more sophisticated

  3. #13
    Basic Member
    Join Date
    Mar 2012
    Posts
    2,017
    Quote Originally Posted by seanjoeut View Post
    Thank you so much for the detailed answer!! I have some experience in Python, Matlab, and a little bit Cpp. (Never really programmed, only researched algorithms so they are all scripting to me XD)
    That's enough for a base
    Quote Originally Posted by seanjoeut View Post
    So far I've only changed 5 heroes their ability usage and item purchase, just to see how things work. And they are already wrecking default bots! which gave me a lot of incentive to learn Lua just to play with this
    Good job!
    Quote Originally Posted by seanjoeut View Post
    I haven't used any feature that seems Lua specific, just basic logics and tables. I don't know callbacks at all, I can only guess from name that it's some event outside of your script that calls the function you passed in? Anyways guess I should be doing some readings and experiments while I make my bot a bit more sophisticated
    As a short answer: yes.it's slightly a bit more complicated but the simple answer is just that. You call a function and after that function finishes execution, you tell it to call a different function (which is the callback). Sort of like "Tell Mike when you're done doing what I asked you to do", "Mike" being the callback and "what I asked you to do" being the initial call. One caveat of this is that the callback almost always happens from another thread. Since D2 runs on its own main thread (and Lua), I suspect that the callback happens in another env (you can think of it as "another context").

    In a callback concept, this has serious implications as a separate thread (or in our case, a separate environment) means you won't have access to the context from which you called the initial function (that put all this in motion). In D2, for example, you can't have a bot context. So GetBot() doesn't work.

    This is what I mean:
    Code:
    local function SomeCallbackEvent()
        -- this is called in context2 - which may or may not be the team context, but it is NEVER the bot context
        print("I was called automatically so I can't use GetBot() here because it won't return anything");
    end
    
    -- this is called by you in context1 (let's call it the "bot context") and you tell it to call SomeCallbackEvent() after all is done in InitialFuncThatCallsACallbackAfterItsDone(); here, as you can see, you have access to GetBot()
    InitialFuncThatCallsACallbackAfterItsDone(GetBot(), SomeCallbackEvent);
    ... this is because it's called by the engine, not by "the bot".

    As I said, there's a lot more to it, but this is the overly simplified version
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •