How is your calling stuff from EndScene concept? menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How is your calling stuff from EndScene concept?

    Hi there,

    I finally managed to hook EndScene and was hoping for come conceptional help. I mean how are you guys getting your object list from there or how are you executing lua functions? Is the following rough concept ok?

    Code:
    private static void EndScene() 
    {
    ObjectManager.Pulse();
    MyMainForm.UpdatePlayerStatus(SomeSortOfStatus);
    MyFiniteStateMachine.Pulse();
    }
    Are you starting your own Finite State Machine as separated thread and have just the Pulse() function do all the stuff?

    How are you handling your main form? Started in your own thread? Then how are you communicating with it in process?

    I am for example updating the status text field as follows. Is that ok or will I get problems in future?

    Code:
     delegate void delegateUpdateStatus(string message);
            public void UpdateStatus(string message) 
            {          
                if (textBox1.InvokeRequired)
                {
                    delegateUpdateStatus d = new delegateUpdateStatus(UpdateStatus);
                    this.Invoke(d, new object[] { message });
                }
                else
                {
                    textBox1.AppendText(DateTime.Now + ": " + message + "\r\n");
                }
            }
    Would be nice to hear something conceptual
    Viano

    How is your calling stuff from EndScene concept?
  2. #2
    tanis2000's Avatar Active Member
    Reputation
    39
    Join Date
    Feb 2009
    Posts
    123
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First of all: are you going to do it as a fully injected process or with the GUI running as a separate process?

  3. #3
    Robske's Avatar Contributor
    Reputation
    305
    Join Date
    May 2007
    Posts
    1,062
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not really that hard or complicated, I currently have the following code flow:

    - Critical data iteration (Such as EnumVisibleObjects)
    - Bot logic (PvP/PvE/Gatherer logic)
    - Extension logic (Hacks, Tools & Tests)
    - GUI Drawing (DirectX, no windows forms/wpf)

    I'm not running into any threading problems because my GUI is governed by the same thread my code is executed on. If you are using windows forms I guess Invoke/BeginInvoke should do the trick...

  4. #4
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by tanis2000 View Post
    First of all: are you going to do it as a fully injected process or with the GUI running as a separate process?
    Everything is injected. So the only thing I can mess up is threading I guess.

    For example if I do the following (rather pseudo code) on every 50th frame the game pauses for like a second. That's why I ask for the best way to do things

    Code:
    private static void EndScene() 
    {
    ObjectManager.Instance.Pulse();
    foreach (WoWObject obj in ObjectManager.Instance.WoWObjects.Values)
    {
    MainForm.ShowObjectName(obj.Name);
    }
    }
    Viano

  5. #5
    !@^^@!'s Avatar Active Member
    Reputation
    23
    Join Date
    Feb 2007
    Posts
    155
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if i were you i would send the whole list of objects to the form and do the foreach loop there in a backgroundworker

  6. #6
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by !@^^@! View Post
    if i were you i would send the whole list of objects to the form and do the foreach loop there in a backgroundworker
    Well yes that is one thing, but is it ok to get the whole object list every frame or rather every 600 frames?

    And how do you call DoString? Are you checking if a variable is set to true in EndScene and then execute it? So for example like that.

    Code:
    EndScene() 
    {
    if (ExecuteDoString == true) { DoString(command); }
    }
    Or maybe event based?
    Viano

  7. #7
    Robske's Avatar Contributor
    Reputation
    305
    Join Date
    May 2007
    Posts
    1,062
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Viano View Post
    Well yes that is one thing, but is it ok to get the whole object list every frame or rather every 600 frames?

    And how do you call DoString? Are you checking if a variable is set to true in EndScene and then execute it? So for example like that.

    Code:
    EndScene() 
    {
    if (ExecuteDoString == true) { DoString(command); }
    }
    Or maybe event based?
    What.

    Your bot logic should be executed in the context of EndScene, not that of your GUI. The GUI should be nothing more than a visualisation of what's going on, not the actual brain.
    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding
    "I cried a little earlier when I had to poop" - Sku

  8. #8
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Robske View Post
    What.

    Your bot logic should be executed in the context of EndScene, not that of your GUI. The GUI should be nothing more than a visualisation of what's going on, not the actual brain.
    ^^ this. I don't even like in-game UI's. Too much cruft for what you get.
    Don't believe everything you think.

  9. #9
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello there,

    I am still having issues with the EndScene concept.

    For example: Movement. If your movement logic is pulsed every frame then how are you handling it? ClickToMove() every 10 frames until your target spot is reached?

    Can anyone provide pseudo code/logic for his movement in the finite state machine executed in EndScene please?
    Viano

  10. #10
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have an navigation backend, which supplies my movement engine with the next point to go.
    The pro of that is that I can use any navigation logic (from simple waypoints to more complex stuff like navigation meshes) as backend without even changing a single line in my movement engine

    Then I check every frame if the point is reached, if yes I request the next point from the backend.
    Hey, it compiles! Ship it!

  11. #11
    !@^^@!'s Avatar Active Member
    Reputation
    23
    Join Date
    Feb 2007
    Posts
    155
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Viano, you should look into FSM and behavior trees because coding ALL you logic with a whole bunch of if cases is gonna be a mess

  12. #12
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a FSM. Nevertheless I am having a hard time designing the movement state which is pulsing in EndScene. Are you clicking every frame or are you posting key up and down every frame (which would be an overkill pushing a key 60 times per second)?

    Flo answered my question partially, he is clicking a calculated (in background) point until it is reached.
    Viano

  13. #13
    !@^^@!'s Avatar Active Member
    Reputation
    23
    Join Date
    Feb 2007
    Posts
    155
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oooh okay sorry i missunderstood you, well I think you should read you current position and if you're a certain distance from the clicked point then click the next point in the queue or what you're using, otherwise do nothing

    pesudo code:

    Code:
    StateExecute()
    {
    if(distance(me.currentPos, LastClickedPos) < 1)
    {
    Ctm(NextPos);
    }
    }
    Last edited by !@^^@!; 03-07-2010 at 11:39 AM.

  14. #14
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After you think about it for a while, you realize how simple it is. Just check if you're really close to the point, if so, start for next point. You can add simple 'stuck' checks in there, too.

    Code:
    static ulong moveCounter = 0;
    Location oldLoc = ...;
    Move()
    {
    if(me.Pos.Distance(me.Destination) < 1)
    {
    Turn(NextPos);
    }
    
    if(moveCounter % 30 == 0)
    {
    if(me.Pos.distance(oldLoc) < 2)
    {
    /*Handle stuck here*/
    }
    oldLoc = me.Pos;
    }
    ++moveCounter;
    }

  15. #15
    nitrogrlie's Avatar Member
    Reputation
    11
    Join Date
    Oct 2009
    Posts
    81
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My Logic:

    Inside EndScene I call RunBot()

    Inside RunBot() I call:
    1) Check timestamp to see if we should execute (currently use 0.2 second frequency)
    2) Update sensors
    3) Determine what is happening
    4) Come up with a plan of what to do
    5) Do it

    so: Sense -> Understand -> Plan -> Execute

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 04-12-2011, 05:44 PM
  2. Replies: 0
    Last Post: 05-30-2010, 12:05 AM
  3. How to make a movie from what u see on your monitor?
    By markons in forum Community Chat
    Replies: 4
    Last Post: 04-08-2008, 11:10 AM
All times are GMT -5. The time now is 11:49 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search