Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Giukko

Members
  • Posts

    99
  • Joined

  • Last visited

    Never

Posts posted by Giukko

  1. UPDATED: New AI. Thanks also to Herbert Glarner for his pathfinding code, which was written only for npcs, so I updated and changed various aspects of this code in order to use it for player character. Now when you click on map, character avoids obstacles, npcs and other players and this happens also for npcs when they search for the player to attack him (if npc AI option is on). An animation appears on the point where you click to highlight the destination target. If you click on an npc for targetting, character doesn't moves.
    IMPORTANT NOTE: if you used my code before, now all the code on this forum page is changed, so you should copy all again.
  2. UPDATE: fixed mouse coordinates just with CurX and CurY, and changed variables TX and TY with name TTX and TTY in order to not have conflicts with same name variables.

    UPDATED: New AI. Thanks also to Herbert Glarner for his pathfinding code, which was written only for npcs, so I updated and changed various aspects of this code in order to use it for player character. Now when you click on map, character avoids obstacles, npcs and other players and this happens also for npcs when they search for the player to attack him (if npc AI option is on). An animation appears on the point where you click to highlight the destination target. If you click on an npc for targetting, character doesn't moves.
    IMPORTANT NOTE: if you used my code before, now all the code on this forum page is changed, so you should copy all again.
    Below the new source code:

    Addictional note: on regard mouse x y problems, see my post: https://www.eclipseorigins.com/topic/86406/fixed-use-of-the-mouse
    Hi all, here I show you the code in order to click on the map and move your character. ...and with double click character starts running :) PS: with this code also you can use keyboard without problems. Code is written to avoid character movements when you click on menus, chat-scroll and hotbar. I also added function which when you click on map all menu windows will be closed.

    Here all the code parts:

    1- install Visual Basic 6 on your computer

    2- Open your Client folder and put this animation (or use the animation which you prefer) inside path: `data files->graphics->animation`. Here is the png file for this exaple: ![](https://i.imgur.com/ke3aFAR.png[/img]) Save this image with name: `13`

    3- Start `Eclipse Renewal.exe`, login, check on `Eclipse Renewal Server` to have the owner status for your character, write on chat `/admin` and open Development Panel. Search for animations editor, create a new animation called `click` and in option -> `Layer 0 (below player)` use this parameters: `loop count = 1`, `frame count = 20`, `loop time = 70`, `sprite = 13`.
    Remember the index number of your new animation, save all and close `Eclipse Renewal.exe` .

    4- Download this file https://filehost.net/f8f8daebba360bb9 (is the new pathfinding module for Client version - another one is on Server.vbp only for npcs)and copy it in `src` folder which is inside `Client` folder.

    4- open `Client.vbp`

    5- Using Visual Basic, search for modules and right click on one of them, then choose `add`->`module`->`existing` and select inside `Client/src/` folder, your new `modPathfinding` file previously downloaded. Save `Client.vbp`.

    6- Search inside module named `modTypes` for `Private Type PlayerRec` and before the `End Type` put this:
    ```
    ' pathfinding
    arPath() As tPoint
    hasPath As Boolean
    pathLoc As Long
    ```

    7- Search `modGlobals ` and in an empty space put:
    ```
    ' PlayerPathfinding
    Public TTX As Long
    Public TTY As Long
    Public Hurry As Boolean
    ```

    8- Search `modInput` and after any `end sub`, paste this code:
    ```
    Public Sub CheckPlayerPathfinding()
    Dim Anim As Byte
    Dim MapNpcNum As Long
    ' //////////////////////////////////////////
    ' // This is used for Player pathfinding //
    ' //////////////////////////////////////////

    'check for click on npcs, in this case character doesn't moves
    For MapNpcNum = 0 To MAX_NPCS

    If MapNpc(MapNpcNum).x = TTX And MapNpc(MapNpcNum).y = TTY Then
    Hurry = False
    mouseDown = False
    Exit Sub
    End If
    Next

    ' if character reaches destination stop it
    If TTX = GetPlayerX(MyIndex) And TTY = GetPlayerY(MyIndex) Then
    Hurry = False
    mouseDown = False
    Exit Sub

    Else
    CreatePathMatrix

    ' animation on click
    For Anim = 1 To MAX_BYTE

    With AnimInstance(Anim)
    .Animation = 13 ' or remeber the number on index animation which you created before
    .x = TTX
    .y = TTY
    .LockType = 0
    .lockindex = 0
    .Used(0) = True
    .Used(1) = True
    End With
    Next

    ' check for double click --> running!
    If Hurry Then
    ShiftDown = True
    Else
    ShiftDown = False
    End If


    ' if map has a working matrix, use a* pathfinding
    If mapMatrix(Player(MyIndex).Map).created Then

    If GetPlayerX(MyIndex) <> TTX Or GetPlayerY(MyIndex) <> TTY Then
    ' map click has changed, re-find the path
    Player(MyIndex).hasPath = APlus(CLng(GetPlayerX(MyIndex)), CLng(GetPlayerY(MyIndex)), CLng(TTX), CLng(TTY), Void, Player(MyIndex).arPath)
    ' set the player cur path location
    If Player(MyIndex).hasPath Then Player(MyIndex).pathLoc = UBound(Player(MyIndex).arPath)
    End If
    ' if has path, follow it
    If Player(MyIndex).hasPath Then
    ' follow path
    PlayerMoveAlongPath

    End If
    End If

    End If

    End Sub
    ```
    9- Again in `modInput` search for `Public Sub CheckInputKeys()`, delete all this `Sub` and paste this one:
    ```
    Public Sub CheckInputKeys()
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo ErrorHandler


    If GetKeyState(vbKeyShift) < 0 Then
    ShiftDown = True
    Else
    ShiftDown = False
    End If

    If GetKeyState(vbKeyReturn) < 0 Then
    CheckMapGetItem
    End If

    If GetKeyState(vbKeyControl) < 0 Then
    Hurry = False
    mouseDown = False
    ControlDown = True
    DirUp = False
    DirDown = False
    DirLeft = False
    DirRight = False
    Exit Sub
    Else
    ControlDown = False
    End If

    ' da reimplementare per magia rapida (copia e incolla codice da versione precedente in chekattack)
    If GetKeyState(vbKeyY) < 0 Then
    Ypsilon = True
    Else
    Ypsilon = False
    End If

    'Move Up
    If GetKeyState(vbKeyUp) < 0 Then
    Hurry = False
    mouseDown = False
    DirUp = True
    DirDown = False
    DirLeft = False
    DirRight = False
    ControlDown = False
    Exit Sub
    Else
    DirUp = False
    End If

    'Move Right
    If GetKeyState(vbKeyRight) < 0 Then
    Hurry = False
    mouseDown = False
    DirUp = False
    DirDown = False
    DirLeft = False
    DirRight = True
    ControlDown = False
    Exit Sub
    Else
    DirRight = False
    End If

    'Move down
    If GetKeyState(vbKeyDown) < 0 Then
    Hurry = False
    mouseDown = False
    DirUp = False
    DirDown = True
    DirLeft = False
    DirRight = False
    ControlDown = False
    Exit Sub
    Else
    DirDown = False
    End If

    'Move left
    If GetKeyState(vbKeyLeft) < 0 Then
    Hurry = False
    mouseDown = False
    DirUp = False
    DirDown = False
    DirLeft = True
    DirRight = False
    ControlDown = False
    Exit Sub
    Else
    DirLeft = False
    End If

    ' Error handler
    Exit Sub
    ErrorHandler:
    HandleError "CheckInputKeys", "modInput", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
    End Sub
    ```
    10- Now search in `modGeneral` for `Public Sub GuiDblClickSearch` and find this line:

    `Dim lines As Long, count As Byte, Width As Long`

    after this one, paste:
    ```
    If GetGuiElement(X, Y) = 0 And GetBtnElement(X, Y) = 0 Then
    'Pathfinding in running mode!
    mouseDown = True
    Hurry = True
    TTX = CurX
    TTY = CurY
    For i = 1 To NumGUI
    GUI(i).Visible = False
    Next
    For i = 1 To NumButtons
    BTN(i).State = 0
    Next
    GUI(GUI_CHAT).Visible = True
    GUI(GUI_HOTBAR).Visible = True
    GUI(GUI_STATS).Visible = True
    GUI(GUI_DRAGBOX).Visible = False
    End If
    ```
    11- Again in `modGeneral` search for `Public Sub GuiDownSearch` and find this line: `Select Case GetGuiElement(X, Y) `, after this one, paste:
    ```
    Case GUI_CHARACTER
    Exit Sub

    Case GUI_OPTIONS
    Exit Sub
    ```
    12- Stay again in `modGeneral` and search for `Public Sub BtnDownSearch` and find this lines:

    `For i = 1 To NumButtons`
    `BTN(i).State = 0`
    `Next`

    after `next`, paste this code:
    ```
    If GetGuiElement(X, Y) = 0 And GetBtnElement(X, Y) = 0 Then
    mouseDown = True
    Hurry = False
    TTX = CurX
    TTY = CurY
    For i = 1 To NumGUI
    GUI(i).Visible = False
    Next
    For i = 1 To NumButtons
    BTN(i).State = 0
    Next
    GUI(GUI_CHAT).Visible = True
    GUI(GUI_HOTBAR).Visible = True
    GUI(GUI_STATS).Visible = True
    GUI(GUI_DRAGBOX).Visible = False
    End If
    ```
    13- Search in `modGameLogic` inside `Sub GameLoop` for the line:
    `Call CheckInputKeys ' Check which keys were pressed`

    end after this one paste:
    ```
    'Player Pathfinding
    If mouseDown Then Call CheckPlayerPathfinding
    ```
    14- That's it. You now have character pathfinding after any click and he/she starts running after double click and evitates obstacles ;)

    15- Extras: I'll update this point for npcs avoids players and other npcs.

    Please let me know if I forgot something :)
  3. Yes, anyway if you have big space (cell size, not the image )for sprites is important to change value to x and y position of Character text names. To better understand, you should imagine to have a png file with a width size of 600, then subdivide 600 for exaple for 4 frames, result of each frame cell will be 150 (in width) and these are columns (in this case 4) of your framesheet.
  4. `UPDATED`
    Hi, mouse click on character and npcs now works properly, just do this:
    - inside Client code, `HandleMouseMove` on this two lines:

    `CurY = TileView.Top + (((Y + Camera.Top) * ((MAX_MAPY * PIC_Y) / screenY)) \ PIC_Y)`
    `CurX = TileView.Left + (((X + Camera.Left) * ((MAX_MAPX * PIC_X) / screenX)) \ PIC_X)`

    delete and paste this:

    `CurX = TileView.Left + ((((X + 16) + Camera.Left) * ((MAX_MAPX * PIC_X) / screenX)) \ PIC_X)`
    `CurY = TileView.Top + ((((Y + 16) + Camera.Top) * ((MAX_MAPY * PIC_Y) / screenY)) \ PIC_Y)`

    Then if you find issues at inventory, spells etc..., to fix mouse movements and clicks do this steps:

    - search `Call GuiDblClickSearch(X , Y)` and change it with `Call GuiDblClickSearch(X - 16, Y)`

    - search `Call GuiUpSearch(Button, Shift, X , Y)` and change it with `Call GuiUpSearch(Button, Shift, X - 16, Y)`

    - search `Call GuiMoveSearch(Button, X, Y)` and change it with `Call GuiUpSearch(Button, Shift, X - 16, Y)`

    - search `Call GuiDownSearch(Button, X, Y)` and change it with `Call GuiDownSearch(Button, X - 16, Y)`

  5. ANOTHER UPDATE: see first post (I hope this is the last one ;) )


    - fixed the speed for attacks based on agility and weapon type (you can see this both inside game mechanics when character fights and by the variable speed of frames during fight)
    - fixed the attack damage from the character, so now when you hold down ctrl key, character starts his attack and continuously tryes to give damage at his enemies
    Note: from this point is important to better calibrate on which factors is attack speed regulated.
  6. Ok, no, right now all the png files must have a space for battle frames, but I think that with a little code improvement and variables it is possible to say at the software if that character or npc as 6 or more, or less columns inside png file. Anyway this is a start point, now I post everything, I'm preparing all the stuffs in order to post them
  7. @alexoune001 Hi alexoune001, no problem for your english, I'm italian and also my english is very bad eheh ;) About your question: yes, is possible. I finished to check everything, in few minutes I'll publish the all code and explanations. My code right now works and I made many test, so seem that there are no bugs for now eheh. Anyway I hope that Mohenjo, which is a more good programmer, will help us to perfectioning the code if needed ;) Now I prepare the tutorial and I post everything, step by step :)
  8. @mohenjo-daro Hi Mohenjo, it is possible to prepare a png spritesheet with more columns in order to have as many frames you need to use. For exaple you could create two new frames for battle, and two new frames for casting spells. Than, when you have a character model, you can use it in order to create via Photoshop as many npc you need, or just using for example arms of your first character model to make a new spritesheet with battle animation also for npc. Anyway, I'll show you everything, also with images, when I finish to fix some stuffs. Actually, I do not find a way to fix the target-image, which appears when mouse pointer is a little too far from the character or npc target. I'll update you soon, any suggestion is welcome and also any help ;)
  9. @kouga Eheh thanks, the new battle frames are added on the right of the spritesheet (png file). Actually I'm checking for possible bugs and I need to fix better the graphic result about the final animation.

    Anyway with this method is possible to use as many frames as you would like ;)) And this is also valid for walking animation. Also I will improve (with the same method) animations during spell casting. I also improved the cell-space of every frame, in order also to use more long weapons. As written before, when I'll finish the tests, I'll publish the source code with an explanation ;)
×
×
  • Create New...