Rob Janes Posted February 2, 2011 Author Share Posted February 2, 2011 Some people have been wondering how to add WASD movement to EO. It's not that difficult to do; the 'easiest' way to do it, uses a Boolean that is set to either True or False depending on if the player has clicked on the Map (Enabled WASD) or if they have clicked on the chat area (Disabling WASD). Enjoy another Tutorial!All changes are done via the Client!Step 1\. In modGeneral, Sub SetFocusOnChat, comment out the part where it sets focus on txtMyChat.```'frmMain.txtMyChat.SetFocus```Step 2\. We need to add a Boolean (True/False) to see if we are typing a message or moving. In modGlobals Add.```'Are We Talking or Moving?Public ChatFocus As Boolean```Step 3\. On frmMain, picScreen's MouseDown event, we want to set this flag (ChatFocus) as False, we're going to add it in right after where it says SetFocusonChat. Like so```Call SetFocusOnChatChatFocus = False```Step 4\. On frmMain, txtMyChat, use the drop down at the top right and select 'click'. There isn't anything in it's 'Click' event right now, only the 'Change' event. What we need to do is set the ChatFocus flag to 'True' if they 'Click' on the textbox. Add this to txtMyChat's Click Event.```ChatFocus = True```Step 5\. Now we are going to add the movement in, so in modInput, sub CheckInputKeys, Just after it checks the Arrow Keys, so at the 'end' of CheckInputKeys, add```'If we aren't focused on the chat, let's see if we use W/A/S/D to move If ChatFocus = False Then 'Move Up (W) If GetKeyState(vbKeyW) < 0 Then DirUp = True DirDown = False DirLeft = False DirRight = False Exit Sub Else DirUp = False End If 'Move Right (D) If GetKeyState(vbKeyD) < 0 Then DirUp = False DirDown = False DirLeft = False DirRight = True Exit Sub Else DirRight = False End If 'Move down (S) If GetKeyState(vbKeyS) < 0 Then DirUp = False DirDown = True DirLeft = False DirRight = False Exit Sub Else DirDown = False End If 'Move left (A) If GetKeyState(vbKeyA) < 0 Then DirUp = False DirDown = False DirLeft = True DirRight = False Exit Sub Else DirLeft = False End If End If```Step 6\. Now we just want to simply set the default's so in modGeneral, under the GameInit sub, just after it does Call SetFocusOnChat, add```'By Default, we automatically want to Target the Chat Window so players can chat 'You could choose to set this flag as false if you wanted to ChatFocus = True frmMain.txtMyChat.SetFocus```Hope you all enjoy! This was built on a clean EO 1.3.1 build!Feel free to request more tutorials! Link to comment Share on other sites More sharing options...
Doom_real Posted February 2, 2011 Share Posted February 2, 2011 The script works fine except that when i click on the chat box i can write on it.Idk how to explain but I can type not just on the box that you use to type an message but on entire chat box.Hope you understand my bad english. Link to comment Share on other sites More sharing options...
Rob Janes Posted February 2, 2011 Author Share Posted February 2, 2011 Sounds like you are clicking on the RichTextBox (txtChat) where messages are written, try clicking on the txtMyChat box, the smaller one where you would write messages. Make sure you added the flag to the txtMyChat.An easy fix to your issue would be on the txtChat Click event, add```ChatFocus=TruetxtMyChat.setFocus``` Link to comment Share on other sites More sharing options...
Guest Posted February 2, 2011 Share Posted February 2, 2011 Personally I think that making an option in the options menu would be better, but yeah, nice tutorial. Link to comment Share on other sites More sharing options...
Murdoc Posted February 2, 2011 Share Posted February 2, 2011 Awesome! I'm gonna use this. Thanks for sharing! (^_^) Link to comment Share on other sites More sharing options...
Rob Janes Posted February 2, 2011 Author Share Posted February 2, 2011 Adding an Option would be easy, use this same modification but if the Option for WASD movement is disabled, then don't bother checking the vbKeyW/A/S/D etc. :) Simple. Link to comment Share on other sites More sharing options...
Guest Posted February 2, 2011 Share Posted February 2, 2011 I know, I was just saying, as a design choice it would be better, imo. Link to comment Share on other sites More sharing options...
Rob Janes Posted February 2, 2011 Author Share Posted February 2, 2011 Agreed. Link to comment Share on other sites More sharing options...
pigboss Posted February 2, 2011 Share Posted February 2, 2011 I want you. so bad.maroon 5 songbut thanks for sharing man. Link to comment Share on other sites More sharing options...
Murdoc Posted February 2, 2011 Share Posted February 2, 2011 @Pigboss:> I want you. so bad.> > maroon 5 song> > but thanks for sharing man.(?_?) Link to comment Share on other sites More sharing options...
Irhymer Posted February 2, 2011 Share Posted February 2, 2011 Nice tut man. Works perfectly in 1.4.0 (incase anyone was wondering) ;)-Jake Link to comment Share on other sites More sharing options...
Boko Posted February 6, 2011 Share Posted February 6, 2011 I would personally use the return key to set focus on the chat box, then when a message is entered, the return key of course sends the message and it loses focus again. Having to use the mouse constantly to type would probably be irritating. Link to comment Share on other sites More sharing options...
shado360 Posted February 6, 2011 Share Posted February 6, 2011 @Boko, that's what mine is using ;D, great minds think alike!Regards,Païn Link to comment Share on other sites More sharing options...
Boko Posted February 7, 2011 Share Posted February 7, 2011 @Päïñ:> @Boko, that's what mine is using ;D, great minds think alike!> > Regards,> PaïnWell I play WoW so I'm use to it :PFor those interested in the return key toggle chat method, here's the code:(Full Client Side, it's not too different to the OP's method)**(Updated with fix from 2nd page)****In modGlobals:**_Add:_```' Chat FocusPublic ChatFocus As BooleanPublic KeyDown As Boolean```**In modGeneral:**_Replace entire_ **Public Sub SetFocusOnChat** _with:_```Public Sub SetFocusOnChat() On Error Resume Next 'prevent RTE5, no way to handle error If ChatFocus = False Then ChatFocus = True frmMain.txtMyChat.SetFocus ElseIf ChatFocus = True Then ChatFocus = False frmMain.picScreen.SetFocus End IfEnd Sub```**In modGeneral:**_In_ **Sub GameInit**_, just before_ **Call SetFocusOnChat**_, Add:_```ChatFocus = True ' Default to screen focus```_Also, move the following above the_ **Call SetFocusChat** _instead of below it (because it's not possible to set focus on picScreen if it's not visible yet)_```frmMain.picScreen.Visible = True```**In modInput:**_Replace:_```If GetKeyState(vbKeyReturn) < 0 Then CheckMapGetItemEnd If```_With: (Replace_ **NEWKEY** _with which ever key you'd prefer to have for picking up items)__(If you're going the route of WASD movement, a key like Q wouldn't be a bad choice, replace with_ **vbKeyQ** _for example)_```If GetKeyState(vbKeyNEWKEY) < 0 Then CheckMapGetItemEnd If```_Just under or above that add:_```If GetKeyState(vbKeyReturn) < 0 And KeyDown = False Then KeyDown = True ElseIf Not GetKeyState(vbKeyReturn) < 0 And KeyDown = True Then KeyDown = False Call SetFocusOnChat End If```You may now also add OP's WASD movement config to this **modInput** _file.__But I recommend just adding Or statements to the arrow key ones instead of making new individual statements, for example:__Replace:_```If GetKeyState(vbKeyUp) < 0 Then```_With:_```If GetKeyState(vbKeyUp) < 0 Or GetKeyState(vbKeyW) < 0 Then```_You will still need the_ **ChatFocus** _if statement around them to ensure you're not moving when typing w/a/s/d.You may also prefer to wrap it around all the key presses to ensure when you're typing, you're only typing. (If you were to attempt to paste something in to the chat for example and you're standing next to someone, you're going to end up accidentally hitting them by the control key press.)_**Optional Step:****In frmMain (Code):**_In_ **Private Sub picScreen_MouseDown** _Remove/Comment:_```Call SetFocusOnChat```_(This causes the return key to be the only method of switching focus, but it's not required.. personally preference)_I might be forgetting something, I patched this up in just a couple minutes by looking at OP's code. Link to comment Share on other sites More sharing options...
Kradon Posted February 8, 2011 Share Posted February 8, 2011 @Boko:> Well I play WoW so I'm use to it :P> > For those interested in the return key toggle chat method, here's the code:> (Full Client Side, it's not too different to the OP's method)> **In modGlobals:**> _Add:_> ```> ' Chat Focus> Public ChatFocus As Boolean> ```> **In modGeneral:**> _Replace entire_ **Public Sub SetFocusOnChat** _with:_> ```> Public Sub SetFocusOnChat()> On Error Resume Next 'prevent RTE5, no way to handle error> If ChatFocus = False Then> ChatFocus = True> frmMain.txtMyChat.SetFocus> ElseIf ChatFocus = True Then> ChatFocus = False> frmMain.picScreen.SetFocus> End If> End Sub> ```> **In modGeneral:**> _In_ **Sub GameInit**_, just before_ **Call SetFocusOnChat**_, Add:_> ```> ChatFocus = True ' Default to screen focus> ```_Also, move the following above the_ **Call SetFocusChat** _instead of below it (because it's not possible to set focus on picScreen if it's not visible yet)_> ```> frmMain.picScreen.Visible = True> ```> **In modInput:**> _Replace:_> ```> If GetKeyState(vbKeyReturn) < 0 Then> CheckMapGetItem> End If> ```_With: (Replace_ **NEWKEY** _with which ever key you'd prefer to have for picking up items)_> _(If you're going the route of WASD movement, a key like Q wouldn't be a bad choice, replace with_ **vbKeyQ** _for example)_> ```> If GetKeyState(vbKeyNEWKEY) < 0 Then> CheckMapGetItem> End If> ```> _Just under or above that add:_> ```> If GetKeyState(vbKeyReturn) < 0 Then> Call SetFocusOnChat> End If> ```> You may now also add OP's WASD movement config to this **modInput** _file._> _But I recommend just adding Or statements to the arrow key ones instead of making new individual statements, for example:_> _Replace:_> ```> If GetKeyState(vbKeyUp) < 0 Then> ```_With:_> ```> If GetKeyState(vbKeyUp) < 0 Or GetKeyState(vbKeyW) < 0 Then> ```> _You will still need the_ **ChatFocus** _if statement around them to ensure you're not moving when typing w/a/s/d.> You may also prefer to wrap it around all the key presses to ensure when you're typing, you're only typing. (If you were to attempt to paste something in to the chat for example and you're standing next to someone, you're going to end up accidentally hitting them by the control key press.)_> > **Optional Step:**> > **In frmMain (Code):**> _In_ **Private Sub picScreen_MouseDown** _Remove/Comment:_> ```> Call SetFocusOnChat> ```_(This causes the return key to be the only method of switching focus, but it's not required.. personally preference)_> > I might be forgetting something, I patched this up in just a couple minutes by looking at OP's code.i tried your method and it works great, cant type in the richtextbox with your method but one problem, whenever i press enter it sets focus on chat but once it sets it on chat i need to press enter more than once sometimes to set it off the chat. Link to comment Share on other sites More sharing options...
Rob Janes Posted February 8, 2011 Author Share Posted February 8, 2011 In the client, modInput, under Handlekeypresses, just afterfrmMain.txtMyChat.text = vbNullString,AddSetFocusOnChatThis will make it so as soon as they send the chat message to the server, it focus' back on the game to continue playing. Link to comment Share on other sites More sharing options...
Guest Posted February 8, 2011 Share Posted February 8, 2011 Theres two things:1) This isnt a bug but theres a slight flicker when you hit enter, watch the txtmychat, the 'line' thing that shows you're able to type (dunno what it's called xD).2) This is what probably causes 1, it you can hit enter a million times, if you hold it down for like half a second it will register it as two enters, this probably causes the flicker. I cant tell if the chat focus goes on and off though. Link to comment Share on other sites More sharing options...
Rob Janes Posted February 8, 2011 Author Share Posted February 8, 2011 I'm not entirely sure, I haven't used Boko's mod to my original tutorial.From looking at his code though, I can see where your problem is coming into play. It has to do with how fast the engine does CheckInputKeys and how his SetFocusOnChat automatically changes the flag. So what happens is that if a player holds down Return for a second or 2, it calls SetFocusOnChat a dozen times and continually changes the boolean from True to False. Link to comment Share on other sites More sharing options...
Rob Janes Posted February 8, 2011 Author Share Posted February 8, 2011 When I get some time tonight, I'll write up a different tutorial on how to toggle this using Enter. Link to comment Share on other sites More sharing options...
Guest Posted February 8, 2011 Share Posted February 8, 2011 Exactly. Sometimes enter just doesnt turn the focus on as well, thought I might mention that. Link to comment Share on other sites More sharing options...
Rob Janes Posted February 8, 2011 Author Share Posted February 8, 2011 Yup, I'll re-edit my original tutorial to handle 'toggling' it with 'Enter/Return' a little later this evening. Link to comment Share on other sites More sharing options...
Guest Posted February 8, 2011 Share Posted February 8, 2011 Great, thanks Samu ^^ Link to comment Share on other sites More sharing options...
Boko Posted February 9, 2011 Share Posted February 9, 2011 Ah sorry, I didn't test the code last time so wasn't sure if it'd work okay.It's an easy fix though.The following is changes to my previous code, I've also modified my previous post with these changes.Deffinately works now, just tested it._In_ **modGlobals** _Find:_```' Chat FocusPublic ChatFocus As Boolean```_Under that Add:_```Public KeyDown As Boolean```_In_ **modInput**_In_ **Public Sub CheckInputKeys** _Find:_```If GetKeyState(vbKeyReturn) < 0 Then Call SetFocusOnChatEnd If```_Replace with:_```If GetKeyState(vbKeyReturn) < 0 And KeyDown = False Then KeyDown = TrueElseIf Not GetKeyState(vbKeyReturn) < 0 And KeyDown = True Then KeyDown = False Call SetFocusOnChatEnd If```This now does nothing when the key is press, but then calls the chat focus function when the key is released from being pressed.I'm not completely sure which value the GetKeyState returns for releasing a button from being pressed (I don't think it does), if someone knows then the KeyDown variable is unneccessary and the statement can just be changed to If GetKeyState(vbKeyReturn) = #It's also worth mentioning that the following lines in the **Sub GameInit** in **modGeneral** are not actually neccessary unless your chat is given focuss in some other way to begin with.```'ChatFocus = True ' Default to screen focus 'Call SetFocusOnChat```I personally also removed the **Private Sub txtChat_GotFocus** in **frmMain (Code)** Link to comment Share on other sites More sharing options...
Kradon Posted February 9, 2011 Share Posted February 9, 2011 @Boko:> Ah sorry, I didn't test the code last time so wasn't sure if it'd work okay.> > It's an easy fix though.> The following is changes to my previous code, I've also modified my previous post with these changes.> Deffinately works now, just tested it.> > _In_ **modGlobals** _Find:_> ```> ' Chat Focus> Public ChatFocus As Boolean> ```> _Under that Add:_> ```> Public KeyDown As Boolean> ```> _In_ **modInput**> _In_ **Public Sub CheckInputKeys** _Find:_> ```> If GetKeyState(vbKeyReturn) < 0 Then> Call SetFocusOnChat> End If> ```_Replace with:_> ```> If GetKeyState(vbKeyReturn) < 0 And KeyDown = False Then> KeyDown = True> ElseIf Not GetKeyState(vbKeyReturn) < 0 And KeyDown = True Then> KeyDown = False> Call SetFocusOnChat> End If> ```> This now does nothing when the key is press, but then calls the chat focus function when the key is released from being pressed.> I'm not completely sure which value the GetKeyState returns for releasing a button from being pressed (I don't think it does), if someone knows then the KeyDown variable is unneccessary and the statement can just be changed to If GetKeyState(vbKeyReturn) = #> > It's also worth mentioning that the following lines in the **Sub GameInit** in **modGeneral** are not actually neccessary unless your chat is given focuss in some other way to begin with.> ```> 'ChatFocus = True ' Default to screen focus> 'Call SetFocusOnChat> ```> I personally also removed the **Private Sub txtChat_GotFocus** in **frmMain (Code)**yes it works great now, thanks for the code. Link to comment Share on other sites More sharing options...
Homicidal Monkey Posted February 9, 2011 Share Posted February 9, 2011 you do know that the purpose of wads movement is for games when you require one hand on the mouse. For most mmorpgs, the keyboard is the more important component. Tha's why it isn't supported by default Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now