Giukko
-
Posts
99 -
Joined
-
Last visited
Never
Content Type
Profiles
Forums
Calendar
Posts posted by Giukko
-
-
Anyway I need to fix the png file for a better animation
-
Sorry, gif image doesnt works
-
Hello, I worked to add inside the source code the way to have more then 1 frame during attacks for character and npc.
This study I think is terminated with good results, no more bugs found. All this post is edited again for this final version.
Follow this tutorial step by step to improve your grafical battle system.
`THIRD UPDATE:`
- there was an error on attack timer, now fixed and spells work (see update at point -->4)
`SECOND UPDATE:`
- 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.
`FIRST UPDATE:` work completed with full code and examples. Simplified instructions, all tested, bugs have been found (I hope ehe) and fixed. The attack animation now works properly.
*Note for developers: the `Sub DrawPlayer` had some process related to AttackSpeed which do not have to stay there, so everything was moved in `Sub ProcessAttacks` and `Public Sub CheckAttack()`
Fixed bugs:
- animation did not work properly - fixed
- if character attacks now he cannot moves until ctrl is pressed.
- attack animations and process are separated from movements.
Here the final result (and below this image you will find the full code):
![](https://i.imgur.com/DfAayxY.gif[/img])
Premise: this code is an approach to give battle animations inside ER and because I needed more bigger space for frames I changed also that part of code, so if you would like to remain at the default frame-cell size of ER, during this tutorial I'll explain and highlight to you what is optional.
* added this optional: if you would like to use 96x96 cell-frame size for your spritesheets, you need to change position at the name of your characters, so you have to go in `modText` and search for sub `DrawPlayerName`, then search for `TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).yOffset ` and put the number `- 55`
than search this one: `TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).yOffset - (Tex_Character(GetPlayerSprite(Index)).Height / 4) ` and put the number `+ 55`
1- optional: first of all download this images, one is a sword paperdoll, and the other one is a character spritesheet:
![alt text](https://i.imgur.com/IllpGLn.png[/img]) ___ ![alt text](https://i.imgur.com/LLu6Vbf.png[/img])
As you can see, cell size is big (96x96 pixel)
2- Install Visual Basic 6 and open ER Client.vpb (Visual Basic Project)
3- `*UPDATED:` Go to `modGameLogic` and after an `end sub` at your choice paste this code:
*Note at this step: inside the code posted below, you need to choice which is the number of the frames that you want for battle (named `.step ` inside the code). Columns into spritesheet are counted from 0 (zero). For example, if you have 6 columns (from 0 to 5) into your spritesheet and you would like to use frame 4 and frame 5 for battle, just use that column numbers. Also, if you would like to have more than two frames for battle, before all edit your png spritesheet, then go inside the code below where are the `.step` and write an `elseif` with the number of the new frame that you need to use.
```
Sub ProcessAttacks(ByVal Index As Long)
Dim AttackSpeed As Long
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo ErrorHandler
If Player(Index).Attacking = 1 Then
' qui fa cambiare il tipo di frame
Select Case GetPlayerDir(Index)
Case DIR_UP
If Player(Index).yOffset < 0 Then Player(Index).yOffset = 0
Case DIR_DOWN
If Player(Index).yOffset > 0 Then Player(Index).yOffset = 0
Case DIR_LEFT
If Player(Index).xOffset < 0 Then Player(Index).xOffset = 0
Case DIR_RIGHT
If Player(Index).xOffset > 0 Then Player(Index).xOffset = 0
End Select
Player(Index).Moving = 0
If Player(Index).Step = 4 Then
Player(Index).Step = 5
Else
Player(Index).Step = 4
End If
Else
Exit Sub
End If
' Error handler
Exit Sub
ErrorHandler:
HandleError "ProcessAttacks", "modGameLogic", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub
```
4- `*UPDATED` Now, again inside `modGameLogic`, search the sub `GameLoop`. You have to find this line: `Dim WalkTimer As Long` after this one put: `Dim AttackSpeed As Long` and `Dim Atimer As Long`.
Then, you have to find this:
`If frmMain.picEventChat.Visible Then
frmMain.picEventChat.Visible = False
End If
End If
End If`
After this, paste this code:
```
' Processa l'input degli attacchi
If ATimer < tick Then
' Process all player attacks on the map
For i = 1 To Player_HighIndex
If IsPlaying(i) Then
Call ProcessAttacks(i)
End If
Next i
' speed from weapon and agility
If GetPlayerEquipment(MyIndex, Weapon) > 0 Then
AttackSpeed = Item(GetPlayerEquipment(MyIndex, Weapon)).speed * 0.5
Else
AttackSpeed = 250 - GetPlayerStat(MyIndex, Agility)
End If
ATimer = tick + AttackSpeed
End If
```
5- `*UPDATED:` Stay into `modGameLogic` and search for sub `CheckAttack()`, so, delete all and paste this code:
```
Public Sub CheckAttack()
Dim Buffer As clsBuffer
Dim AttackSpeed As Long, X As Long, Y As Long, i As Long
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo ErrorHandler
If Player(MyIndex).Moving > 0 Then Exit Sub
If ControlDown Then
If SpellBuffer > 0 Then Exit Sub ' currently casting a spell, can't attack
If StunDuration > 0 Then Exit Sub ' stunned, can't attack
If Player(MyIndex).Step = 1 Or Player(MyIndex).Step = 3 Then Player(MyIndex).Step = 0
If Player(MyIndex).AttackTimer + (AttackSpeed * 0.5) < GetTick Then
'Now continue to send the attack at server and the attack works
'If Player(MyIndex).Attacking = 0 Then
With Player(MyIndex)
.Attacking = 1
.AttackTimer = GetTick
End With
Set Buffer = New clsBuffer
Buffer.WriteLong CAttack
SendData Buffer.ToArray()
Set Buffer = Nothing
'End If
End If
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 GetTick > Player(MyIndex).EventTimer Then
For i = 1 To Map.CurrentEvents
If Map.MapEvents(i).Visible = 1 Then
If Map.MapEvents(i).X = X And Map.MapEvents(i).Y = Y Then
Set Buffer = New clsBuffer
Buffer.WriteLong CEvent
Buffer.WriteLong i
SendData Buffer.ToArray()
Set Buffer = Nothing
Player(MyIndex).EventTimer = GetTick + 200
End If
End If
Next
End If
Else
With Player(MyIndex)
.Attacking = 0
.AttackTimer = 0
End With
If Player(MyIndex).Step >= 4 Then Player(MyIndex).Step = 0
Exit Sub
End If
' Error handler
Exit Sub
ErrorHandler:
HandleError "CheckAttack", "modGameLogic", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub
```
6- Again, in `modGameLogic` search for sub `ProcessMovement`, then delete all and paste this code:
```
Sub ProcessMovement(ByVal Index As Long)
Dim MovementSpeed As Long
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo ErrorHandler
If Player(Index).Attacking = 1 Then Exit Sub
' Check if player is walking, and if so process moving them over
Select Case Player(Index).Moving
Case MOVING_WALKING
PlayerMovement(Index) = 1
MovementSpeed = ((ElapsedTime / 800) * (WALK_SPEED * SIZE_X))
Case MOVING_RUNNING
PlayerMovement(Index) = 2
MovementSpeed = ((ElapsedTime / 800) * ((WALK_SPEED + ((GetPlayerStat(Index, Agility) + (Player(Index).Level / 25)) ^ 0.4)) * SIZE_X))
Case Else
PlayerMovement(Index) = 0
Exit Sub
End Select
If GetPlayerVital(MyIndex, Vitals.Sprint) = 0 Then
Player(Index).Moving = MOVING_WALKING
End If
' qui da la velocità di movimento dell'immagine su schermo, non dei frames
Select Case GetPlayerDir(Index)
Case DIR_UP
Player(Index).yOffset = Player(Index).yOffset - MovementSpeed
If Player(Index).yOffset < 0 Then Player(Index).yOffset = 0
Case DIR_DOWN
Player(Index).yOffset = Player(Index).yOffset + MovementSpeed
If Player(Index).yOffset > 0 Then Player(Index).yOffset = 0
Case DIR_LEFT
Player(Index).xOffset = Player(Index).xOffset - MovementSpeed
If Player(Index).xOffset < 0 Then Player(Index).xOffset = 0
Case DIR_RIGHT
Player(Index).xOffset = Player(Index).xOffset + MovementSpeed
If Player(Index).xOffset > 0 Then Player(Index).xOffset = 0
End Select
' Check if completed walking over to the next tile
If Player(Index).Moving > 0 Then
If GetPlayerDir(Index) = DIR_RIGHT Or GetPlayerDir(Index) = DIR_DOWN Then
If (Player(Index).xOffset >= 0) And (Player(Index).yOffset >= 0) Then
Player(Index).Moving = 0
If Player(Index).Step = 1 Then
Player(Index).Step = 3
Else
Player(Index).Step = 1
End If
End If
Else
If (Player(Index).xOffset <= 0) And (Player(Index).yOffset <= 0) Then
Player(Index).Moving = 0
If Player(Index).Step = 1 Then
Player(Index).Step = 3
Else
Player(Index).Step = 1
End If
End If
End If
End If
' Error handler
Exit Sub
ErrorHandler:
HandleError "ProcessMovement", "modGameLogic", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub
```
7- `UPDATED:` Now go to `modGraphics` and search for `DrawPlayer`. Delete all the sub and paste this code:
```
Public Sub DrawPlayer(ByVal Index As Long)
Dim Anim As Byte, i As Long, X As Long, Y As Long
Dim Sprite As Long, spritetop As Long
Dim rec As RECT
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo ErrorHandler
Sprite = GetPlayerSprite(Index)
If Sprite < 1 Or Sprite > NumCharacters Then Exit Sub
' Reset frame
If Player(Index).Step = 3 Then
Anim = 0
ElseIf Player(Index).Step = 1 Then
Anim = 2
ElseIf Player(Index).Step = 4 Then
Anim = 0
ElseIf Player(Index).Step = 5 Then
Anim = 0
End If
' Check for attacking animation
If Player(Index).Attacking = 1 Then
Anim = Player(Index).Step
Else
' If not attacking, walk normally
Select Case GetPlayerDir(Index)
Case DIR_UP
If (Player(Index).yOffset > 8) Then Anim = Player(Index).Step
'AddText "Step = " & Player(Index).Step, Yellow
Case DIR_DOWN
If (Player(Index).yOffset < -8) Then Anim = Player(Index).Step
'AddText "Step = " & Player(Index).Step, Yellow
Case DIR_LEFT
If (Player(Index).xOffset > 8) Then Anim = Player(Index).Step
'AddText "Step = " & Player(Index).Step, Yellow
Case DIR_RIGHT
If (Player(Index).xOffset < -8) Then Anim = Player(Index).Step
'AddText "Step = " & Player(Index).Step, Yellow
End Select
End If
' Set the left
Select Case GetPlayerDir(Index)
Case DIR_UP
spritetop = 3
Case DIR_RIGHT
spritetop = 2
Case DIR_DOWN
spritetop = 0
Case DIR_LEFT
spritetop = 1
End Select
With rec
.Top = spritetop * (Tex_Character(Sprite).Height / 4)
.Bottom = .Top + (Tex_Character(Sprite).Height / 4)
.Left = Anim * (Tex_Character(Sprite).Width / 6) 'divide il file png nel numero di colonne indicate
.Right = .Left + (Tex_Character(Sprite).Width / 6) 'divide il file png nel numero di colonne indicate
End With
' Calculate the X (centratura dell'immagine e larghezza massima dell'immagine
' per centrare è necessario inserire quante colonne frames per x e quante righe frames per y
X = GetPlayerX(Index) * PIC_X + Player(Index).xOffset - ((Tex_Character(Sprite).Width / 6 - 32) * 0.5)
' Is the player's height more than 32..?
If (Tex_Character(Sprite).Height) > 32 Then
' Create a 32 pixel offset for larger sprites
Y = GetPlayerY(Index) * PIC_Y + Player(Index).yOffset - ((Tex_Character(Sprite).Height / 4) - 32)
Else
' Proceed as normal
Y = GetPlayerY(Index) * PIC_Y + Player(Index).yOffset
End If
' render the actual sprite
Call DrawSprite(Sprite, X, Y, rec)
' Set player's location
playerLocX(Index) = X
playerLocY(Index) = Y
' check for paperdolling
For i = 1 To UBound(PaperdollOrder)
If GetPlayerEquipment(Index, PaperdollOrder(i)) > 0 Then
If Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll > 0 Then
Call DrawPaperdoll(Index, X, Y, Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll, Anim, spritetop)
End If
End If
Next
' Error handler
Exit Sub
ErrorHandler:
HandleError "DrawPlayer", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub
```
Pay attention inside this code (which is `Public Sub DrawPlayer `) for this two lines:
`.Left = Anim * (Tex_Character(Sprite).Width / 6)`
`.Right = .Left + (Tex_Character(Sprite).Width / 6)`
I changed the original number 4 with (whatever is) the number of columns inside character spritesheet. In this tutorial I used 6 columns, so I putted 6 instead of the original 4 columns.
8- Go to `modGraphics` and search for sub `DrawPaperdoll`. Search inside this sub for those two lines:
` .Left = Anim * (Tex_Paperdoll(Sprite).Width / 4)`
`.Right = .Left + (Tex_Paperdoll(Sprite).Width / 4)`
and change the number 4 with whatever is the number of columns inside your paperdoll spritesheet. In this tutorial I used 6 columns (both for character and paperdoll), so put 6 instead of 4.
9- that's it, have fun ;) -
Very nice work! Waiting for news ;))
-
Good idea, thanks
-
Thanks Eric!!! :)
-
Thanks to you for all other works ;)
-
Fixed this issue on ER, now spell icons are updated. Just put this code inside server source code --> `modPlayer` ----> `UseItem` searching for ---> `Call SetPlayerSpell(Index, i, n)` and after this one put: `Call SendSpells(Index)`
That's it ;) -
@mohenjo-daro Yeah, I'm checking now all his works :))) Very great stuffs from Eric :) And usefull also your advise about which software to use.
-
@mohenjo-daro said in [ER 1\.9\.0 Upcoming](/post/701145):
> rewriting the code that loads all the data at start up <-- great works, also very nice idea to make shadow rotation, right now I putted a piece of code from Andur in order to make shadows also at resources and by the trick of putting house tiles and other buildings also in resources, it's possible to create house shadows for example (connected to an item which is unfindible inside the game in order to not destroy buildings ecc...) Also very interesting the "saving/loading characters" as you wrote here :))) -
Thanks Mohenjo and thanks to all contributors!! Maybe after working on source code I'll post something.
-
@mohenjo-daro :)) Thanks. Mohenjo I saw also that after learning a new spell, the inventory for spells doesnt updates spell icons. The only solution right now is to drag one spell icon and the new one appears, or by closing client and restart it.
-
I searched inside the code why spells after using double click they do not work. The problem is on two wrong written variables, inside "modGeneral" ----> "Public Sub GuiDblClickSearch": change "SpellY" and "SpellX" with just "Y" and "X". that's it (after one hour of searching eheh) ;)
***
In `modGeneral` search for `Public Sub GuiDblClickSearch`
Change `SpellY` to `Y`
Change `SpellX` to `X` -
Solved! :)) I finded ER updater and with the 1.8.3H version this problem is fixed :)) Anyway I warn you that people which download from “download page” they will be redirect to download the older version 1.8.2 and without updater. Thanks again ;)
-
Great!!! Thanks!!! :)
-
I send to you my client with code?
-
Hi Mohenjo, I need your help, with the npc editor, when I’m putting a quest inside an NPC , and than I save the map, and than I push CTRL button of the keyboard near the NPC for calling the quest, nothing happen and the game crash with this error: unrecoverable dx8 error.
Please help me, without quests the game building is nothing :( -
IT WORKS!!!! It was my fault, because I forget to delete from server a variable shadow. Now as you wrote me, with that code it works and save the map!!!!! Thank you!!!!! :)
-
Hehe, my gosh, I would like to start making a world soon with ER or AE but there are many bugs :) Anyway I really appreciate your work, but I'm still stopped waiting for some new major fix ;) Thanks a lot, really ;)
-
Note: I done this from a fresh source code following your instructions and placing also this required piece of code in costants:
* ' Graphics
Public Const Pi As Double = 3.14159265358979
Public Const DegreeToRad As Double = Pi / 180 ' 0.0174533 -
Doesnt works, the game start, I see shadows and character can moves, but when I put something from the map editor and I save, the server crash :( Dont know
-
@mohenjo-daro Eheh great Mohenjo I try now! :))) Thanks!!!!
-
Ah ok, because I simply searched on Andur Engine all pieces of code and pasted on ER in the right position eheh
-
@mohenjo-daro said in [Eclipse Renewal Suggestions](/post/701395):
> I’ll probably end up changing lighting and shadows in a later update
Great!! Thanks :)
I tryed add shadows and client works well, but when I'm saving updates at the map the server crash. Any suggestion? Here is the code which Visual Basic highlight in debug: CopyMemory ByVal VarPtr(Resource(ResourceNum)), ByVal VarPtr(ResourceData(0)), ResourceSize
Could you help me to fix this?
On ER now is possible to have more than 1 frame for attacks
in Tutorials
Posted