Abyssrayel Posted March 24, 2013 Author Share Posted March 24, 2013 ~This Tutorial is for beginners; especially as a learning tool.~*Here is a Step - By - Step Tutorial on how to improve the Character Movement in your game.*~*Pay attention to what you are truly doing while following the tutorial to gain better insight into editing source code.*~First of all, thanks to, daxterxx for making this Tutorial: [http://www.touchofde…oothness-in-eo/](http://www.touchofdeathforums.com/community/index.php?/topic/127177-csde-walking-smoothness-in-eo/)Thanks also go out to, xppxdd for posting this list: [http://www.touchofde...imple-need-vb6/](http://www.touchofdeathforums.com/community/index.php?/topic/100371-tut-how-to-chenge-the-game-keys-very-simple-need-vb6/)EDIT: I almost forgot [ValentineBr](http://www.touchofdeathforums.com/community/index.php?/user/58618-valentinebr/) who found this: [http://www.touchofde...layer-movement/](http://www.touchofdeathforums.com/community/index.php?/topic/129963-bug-fix-correction-player-movement/)***(REMEMBER TO ALWAYS MAKE A BACK-UP OF YOUR PROJECT BEFORE EDITING IT)***Now, we start off by looking at daxterxx's Tutorial and in modGameLogic find:```Select Case Player(Index).Moving Case MOVING_WALKING: MovementSpeed = ((ElapsedTime / 1000) * (RUN_SPEED * SIZE_X)) Case MOVING_RUNNING: MovementSpeed = ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X)) Case Else: Exit SubEnd Select```Then change it to:```Select Case Player(Index).Moving Case MOVING_WALKING: MovementSpeed = WALK_SPEED Case MOVING_RUNNING: MovementSpeed = RUN_SPEEDCase Else: Exit SubEnd Select```Look now and see that your values equal exactly what your walking and running rates are. Feel free to check your standard rates before moving on by logging in and moving around a bit.**STOP!** modGameLogic. **Think** about what you just did. Client Side Only. You just **changed** what your Player MovementSpeed Equals to a Variable. _*****_ _Player_ - Your Sprite in-game. _Movement Speed_ - How fast something moves; in this case your Player. _Equals_ - Describes the relation of complete balance. _Variable_ - A value that is to be used in specific instances to determine a purpose. * _**What do I do next?**_ Find where your WALK_SPEED & RUN_SPEED Variables are located.Now find in modConstants:```' Speed moving varsPublic Const WALK_SPEED As Byte = 4Public Const RUN_SPEED As Byte = 6```Change this to:```' Speed moving varsPublic Const WALK_SPEED As Byte = 3Public Const RUN_SPEED As Byte = 5```What all this does; if you checked the rates, is make you move at a more proper basic speed. Up to this point the whole purpose was to create a base for a new Movement Speed Formula. You now have the most basic part of the Formula.**Example:** "Public Const WALK_SPEED As Byte = 3" this means that if "Case MOVING_WALKING: MovementSpeed = WALK_SPEED" to put it simply, means MovementSpeed = 3.**STOP!** modConstants. **Think**, you just changed the Constant Value of the Variables _WALK_SPEED_ & _RUN_SPEED_. Right before, you changed the Value of MovementSpeed in GameLogic. All together, MovementSpeed of your Player Equals _3_ & _5_ respectivly for Walking and Running. _*****_ _Value_ - A set allowance or amount. _Constant Value_ - A Value that never changes. _WALK_SPEED_ - A Variable that you set for the Value of Walking MovementSpeed. _RUN_SPEED_ - A Variable that you set for the Value of Running MovementSpeed. _3_ - The Value of the Variable WALK_SPEED; that is the Value of Walking MovementSpeed. _5_ - The Value of the Variable RUN_SPEED; that is the Value of Running MovementSpeed. _Walking_ - The Term I gave to Case MOVING_WALKING in modGameLogic. _Running_ - The Term I gave to Case MOVING_RUNNING in modGameLogic.The next step is to change:```' Check if player is walking, and if so process moving them overSelect Case Player(Index).Moving Case MOVING_WALKING: MovementSpeed = WALK_SPEED Case MOVING_RUNNING: MovementSpeed = RUN_SPEEDCase Else: Exit SubEnd Select```To this: (EDIT: Also added ValentineBr's addition)```' Check if player is walking, and if so process moving them overSelect Case Player(Index).Moving Case MOVING_WALKING: MovementSpeed = WALK_SPEED + (Player(MyIndex).Stat(Willpower) / 30) Case MOVING_RUNNING: MovementSpeed = RUN_SPEED + (Player(MyIndex).Stat(Agility) / 15) Case Else: Exit SubEnd SelectIf Player(Index).step = 0 Then Player(Index).step = 1```What this does (took about 2 hours to get a well working formula (ended up being super basic)) is make your new Walking Movement Speed & Running Movement Speed each effected by Willpower & Agility. (So that they aren't always the same & you get faster as you upgrade either skill) **+** "If Player(Index).step = 0 Then Player(Index).step = 1" makes your character's movement look smoother. - _*I will update this formula without notice if/ when I find a better formula*__*Like this post after testing the increase rates with an Admin if you approve*__*That is probably the last formula revision as I find it to be a nice rate & **even with maxed stats you don't cap out the Engine's capabilities**.*_Now on to xppxdd's Post about changing keys.From his post I was able to change the "Run" key to CTRL and the "Attack/ Interact" key to Shift & also be able to move with both the Arrow Keys and W, A, S, D Keys. The purpose of this is so that people can essentially play with one hand on the keyboard and one on the mouse. They also have better control if using both hands on the keyboard.Here's how I did it. In modConstants find:```' Key constantsPublic Const VK_UP As Long = &H26Public Const VK_DOWN As Long = &H28Public Const VK_LEFT As Long = &H25Public Const VK_RIGHT As Long = &H27Public Const VK_SHIFT As Long = &H10Public Const VK_RETURN As Long = &HDPublic Const VK_CONTROL As Long = &H11```Add W, A, S, D Keys bettween RIGHT & SHIFT to get this:```' Key constantsPublic Const VK_UP As Long = &H26Public Const VK_DOWN As Long = &H28Public Const VK_LEFT As Long = &H25Public Const VK_RIGHT As Long = &H27Public Const VK_W As Long = &H57Public Const VK_S As Long = &H53Public Const VK_A As Long = &H41Public Const VK_D As Long = &H44Public Const VK_SHIFT As Long = &H10Public Const VK_RETURN As Long = &HDPublic Const VK_CONTROL As Long = &H11```Now in modInput find:```If GetAsyncKeyState(VK_UP) >= 0 Then DirUp = FalseIf GetAsyncKeyState(VK_DOWN) >= 0 Then DirDown = FalseIf GetAsyncKeyState(VK_LEFT) >= 0 Then DirLeft = FalseIf GetAsyncKeyState(VK_RIGHT) >= 0 Then DirRight = FalseIf GetAsyncKeyState(VK_CONTROL) >= 0 Then ControlDown = FalseIf GetAsyncKeyState(VK_SHIFT) >= 0 Then ShiftDown = False```Add W, A, S, D here, like so:```If GetAsyncKeyState(VK_UP) >= 0 Then DirUp = FalseIf GetAsyncKeyState(VK_DOWN) >= 0 Then DirDown = FalseIf GetAsyncKeyState(VK_LEFT) >= 0 Then DirLeft = FalseIf GetAsyncKeyState(VK_RIGHT) >= 0 Then DirRight = FalseIf GetAsyncKeyState(VK_W) >= 0 Then DirUp = FalseIf GetAsyncKeyState(VK_S) >= 0 Then DirDown = FalseIf GetAsyncKeyState(VK_A) >= 0 Then DirLeft = FalseIf GetAsyncKeyState(VK_D) >= 0 Then DirRight = FalseIf GetAsyncKeyState(VK_CONTROL) >= 0 Then ControlDown = FalseIf GetAsyncKeyState(VK_SHIFT) >= 0 Then ShiftDown = False```Now right under, in Sub CheckInputKeys find:```'Move UpIf GetKeyState(vbKeyUp) < 0 Then DirUp = True DirDown = False DirLeft = False DirRight = False Exit SubElse DirUp = FalseEnd If'Move RightIf GetKeyState(vbKeyRight) < 0 Then DirUp = False DirDown = False DirLeft = False DirRight = True Exit SubElse DirRight = FalseEnd If'Move downIf GetKeyState(vbKeyDown) < 0 Then DirUp = False DirDown = True DirLeft = False DirRight = False Exit SubElse DirDown = FalseEnd If'Move leftIf GetKeyState(vbKeyLeft) < 0 Then DirUp = False DirDown = False DirLeft = True DirRight = False Exit SubElse DirLeft = FalseEnd If```Add the W, A, S, D Keys here as shown:```'Move UpIf GetKeyState(vbKeyUp) < 0 Or GetKeyState(vbKeyW) < 0 Then DirUp = True DirDown = False DirLeft = False DirRight = False Exit SubElse DirUp = FalseEnd If'Move RightIf GetKeyState(vbKeyRight) < 0 Or GetKeyState(vbKeyD) < 0 Then DirUp = False DirDown = False DirLeft = False DirRight = True Exit SubElse DirRight = FalseEnd If'Move downIf GetKeyState(vbKeyDown) < 0 Or GetKeyState(vbKeyS) < 0 Then DirUp = False DirDown = True DirLeft = False DirRight = False Exit SubElse DirDown = FalseEnd If'Move leftIf GetKeyState(vbKeyLeft) < 0 Or GetKeyState(vbKeyA) < 0 Then DirUp = False DirDown = False DirLeft = True DirRight = False Exit SubElse DirLeft = FalseEnd If```To reverse the "Run" and "Attack/ Interact" Keys, in modGameLogic find:```' Check if player has the shift key down for running If ShiftDown Then Player(MyIndex).Moving = MOVING_RUNNING Else Player(MyIndex).Moving = MOVING_WALKING End If```Then change ShiftDown to ControlDown, like so: (Also change the comment to say "control" instead of "shift")```' Check if player has the control key down for running If ControlDown Then Player(MyIndex).Moving = MOVING_RUNNING Else Player(MyIndex).Moving = MOVING_WALKING End If```Then find in Sub CheckAttack:```If ControlDown ThenIf InEvent = True Then Exit Sub Select Case Player(MyIndex).Dir Case DIR_UP X = GetPlayerX(MyIndex) Y = GetPlayerY(MyIndex) - 1 Case DIR_DOWN X = GetPlayerX(MyIndex) Y = GetPlayerY(MyIndex) + 1 Case DIR_LEFT X = GetPlayerX(MyIndex) - 1 Y = GetPlayerY(MyIndex) Case DIR_RIGHT X = GetPlayerX(MyIndex) + 1 Y = GetPlayerY(MyIndex) End Select```Then change ControlDown to ShiftDown as shown:```If ShiftDown ThenIf InEvent = True Then Exit Sub Select Case Player(MyIndex).Dir Case DIR_UP X = GetPlayerX(MyIndex) Y = GetPlayerY(MyIndex) - 1 Case DIR_DOWN X = GetPlayerX(MyIndex) Y = GetPlayerY(MyIndex) + 1 Case DIR_LEFT X = GetPlayerX(MyIndex) - 1 Y = GetPlayerY(MyIndex) Case DIR_RIGHT X = GetPlayerX(MyIndex) + 1 Y = GetPlayerY(MyIndex) End Select```That should be all you have to do! Compile before saving to test if you like the changes or not. Save after testing if you like your changes. && Most of all; ENJOY! ![](http://www.touchofdeathforums.com/community/public/style_emoticons/default/biggrin.png)~*(Please comment what you think of the Tutorial, Source Mod. & any Bugs/ Glitches/ Problems you find)*~ Link to comment Share on other sites More sharing options...
Guest Posted March 24, 2013 Share Posted March 24, 2013 > ' Speed moving vars> > Public Const WALK_SPEED As Byte = 2.75> > Public Const RUN_SPEED As Byte = 5.5Bytes can only be whole numbers. Use Singles. Link to comment Share on other sites More sharing options...
Abyssrayel Posted March 24, 2013 Author Share Posted March 24, 2013 I thought so too, but it seems to work. Now that you mention it, would it just be automatically rounding them?EDIT: Thanks to [- Matthew -](http://www.touchofdeathforums.com/community/index.php?/user/65954-matthew/) for confirming this.EDIT: (Changed in main post)From:```' Speed moving varsPublic Const WALK_SPEED As Byte = 2.75Public Const RUN_SPEED As Byte = 5.5```To:```' Speed moving varsPublic Const WALK_SPEED As Byte = 3Public Const RUN_SPEED As Byte = 5```EDIT: Get a sticky for this? As it's extremely useful for everyone & will be updated until 100% refied. Link to comment Share on other sites More sharing options...
Matt Posted March 24, 2013 Share Posted March 24, 2013 > I thought so to, but it seems to work. Would it just be automatically rounding them?It does. 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