tslusny Posted July 21, 2012 Author Share Posted July 21, 2012 Thx to Zopto for his [base AutoAttack system](http://www.touchofdeathforums.com/smf2/index.php/topic,80725.msg864206.html#new)So this tutorial will make this: If you have target then if you are facing NPC you will autoattack that NPC.CLIENT SIDEIn **frmMain** in **picOptions** create> **Checkbox**> **Name**: chkAutoAttack> **Caption**: Auto attackThen in **mod GameLogic** find this:```If CanMoveNow Then Call CheckMovement ' Check if player is trying to move Call CheckAttack ' Check to see if player is trying to attack End If```Replace it with this:```If frmMain.chkAutoAttack.Value = YES Then If CanMoveNow Then 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 If myTarget > 0 Then If x = MapNpc(myTarget).x And Y = MapNpc(myTarget).Y Then ControlDown = True End If Call checkmovement ' Check if player is trying to move Call CheckAttack ' Check to see if player is trying to attack End If else If CanMoveNow Then 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 Call checkmovement End If``` Link to comment Share on other sites More sharing options...
Zopto Posted July 21, 2012 Share Posted July 21, 2012 Nice… Can you add link of my tut of autoattack to ppl cnow what you fixed Link to comment Share on other sites More sharing options...
tslusny Posted July 21, 2012 Author Share Posted July 21, 2012 @Zopto:> Nice… Can you add link of my tut of autoattack to ppl cnow what you fixedYes Link to comment Share on other sites More sharing options...
Zopto Posted July 21, 2012 Share Posted July 21, 2012 Tnx bro Link to comment Share on other sites More sharing options...
minipimp Posted July 21, 2012 Share Posted July 21, 2012 Im getting the Variable not defined error. on the line " X = GetPlayerX(MyIndex) " Link to comment Share on other sites More sharing options...
Whackeddie99 Posted July 21, 2012 Share Posted July 21, 2012 at the top of the sub putDim X as longDim Y as long Link to comment Share on other sites More sharing options...
minipimp Posted July 22, 2012 Share Posted July 22, 2012 Now only problem is , unless the checkbox is checked the player cannot move. Link to comment Share on other sites More sharing options...
JohnPony Posted July 22, 2012 Share Posted July 22, 2012 ``` If frmMain.chkAutoAttack.Value = YES Then If CanMoveNow Then 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 If myTarget > 0 Then If X = MapNpc(myTarget).X And Y = MapNpc(myTarget).Y Then ControlDown = True End If Call CheckMovement ' Check if player is trying to move Call CheckAttack ' Check to see if player is trying to attack End If End If```Changing it to``` If frmMain.chkAutoAttack.Value = YES Then If CanMoveNow Then 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 If myTarget > 0 Then If x = MapNpc(myTarget).x And Y = MapNpc(myTarget).Y Then ControlDown = True End If Call checkmovement ' Check if player is trying to move Call CheckAttack ' Check to see if player is trying to attack End If else If CanMoveNow Then 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 Call checkmovement End If```Should work, although i couldn't test as i don't have VB6 where i am at the moment. Link to comment Share on other sites More sharing options...
minipimp Posted July 22, 2012 Share Posted July 22, 2012 Compile error : End case without select case :/ Im probably putting it in wrong? Link to comment Share on other sites More sharing options...
JohnPony Posted July 22, 2012 Share Posted July 22, 2012 Probably something wrong with my code, i didn't write it in the IDE.It should work now. Link to comment Share on other sites More sharing options...
tslusny Posted July 22, 2012 Author Share Posted July 22, 2012 Fixed tut thx Pony Link to comment Share on other sites More sharing options...
JohnPony Posted July 22, 2012 Share Posted July 22, 2012 @Deathbeam:> Fixed tut thx PonyAnytime. Link to comment Share on other sites More sharing options...
Wortel Angels Posted July 23, 2012 Share Posted July 23, 2012 Got an error it highlight Loop>Loop without Do< Link to comment Share on other sites More sharing options...
minipimp Posted July 23, 2012 Share Posted July 23, 2012 Same error here too. Link to comment Share on other sites More sharing options...
zerohero Posted July 23, 2012 Share Posted July 23, 2012 Add an extra```End If ```To the end of his code, should fix you right up Link to comment Share on other sites More sharing options...
Wortel Angels Posted July 26, 2012 Share Posted July 26, 2012 Thanks works but i cant attack with CTRL if the checkbox is not checkedTo fix it put under the second``` Call CheckMovement```This``` Call CheckAttack``` Link to comment Share on other sites More sharing options...
Murdoc Posted August 18, 2012 Share Posted August 18, 2012 would this work with auto-target? Link to comment Share on other sites More sharing options...
Wortel Angels Posted August 18, 2012 Share Posted August 18, 2012 yes it works ;-) Link to comment Share on other sites More sharing options...
santa-clause Posted April 28, 2013 Share Posted April 28, 2013 Maybe also add in this tutorialThat they need to add: Dim x As Long, y As LongAfter : Public Sub GameLoop()And the last end if too ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png) 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