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

[EO2.0]Ranged Projectiles(Arrows, Bullets and more)[RELEASE]


evilbunnie
 Share

Recommended Posts

  • Replies 232
  • Created
  • Last Reply

Top Posters In This Topic

@Alexander:

> Why do you have such a high max-range for the speed scrollbar? Anything past 50 is choppy because you have the arrows traveling on a tile-by-tile movement system. Why didn't you use an offset system that makes slower moving arrows actually appear to move slow instead of tile-by-tile?
>
> ::EDIT::
> For the record, I was only testing this out on the precompiled client and server you posted as _Projectiles.zip_

I'm pretty sure it is moving along on it's on course, it's not moving forward 32pixels everytime.. However I made this a long time ago, and if I didn't then I have no idea what state of mind I was in then.

Edit, I remember I did it tile by tile because I was too lazy to do pixel based collision detection. Sorry sir.
Link to comment
Share on other sites

@Captain:

> Edit, I remember I did it tile by tile because I was too lazy to do pixel based collision detection. Sorry sir.

Pixel collision wouldn't have to even be done. You would just render the sprite to animate in a pixel-by-pixel fashion. Pixel movement, however, would require pixel-by-pixel collision checking. That's the same thing as tile-by-tile checking, except you check every one pixel(s) as opposed to ever 32 pixels.
Link to comment
Share on other sites

@cheesymilk:

> First of all thanks for the great Tut, but when I compile I get the following error:
>
> Compile error:
>
> Method or data member not found
>
> it highlights the first .Frame4 within ItemEditorInit
>
> What did I do wrong?

You installed it incorrectly.

Try again **. u .**
Link to comment
Share on other sites

When I added

ProjecTile as ProjectileRec it gave me an error starting with user-type definition or something. When removing it, it gave me

Method or Data member not found.

And highlights .ProjecTile in sub checkattack. I'm 100% sure nothing is wrong, I did exactly as it told me to in tutorial.

Anybody help?
Link to comment
Share on other sites

Small fix for this awesome tutorial to make projectiles be stopped by directional blocking and Resource blocks.

**Server side**

Replace **HandleProjectile** with this:
```
Public Sub HandleProjecTile(ByVal Index As Long, ByVal PlayerProjectile As Long)
Dim x As Long, y As Long, i As Long

    ' check for subscript out of range
    If Index < 1 Or Index > MAX_PLAYERS Or PlayerProjectile < 1 Or PlayerProjectile > MAX_PLAYER_PROJECTILES Then Exit Sub

    ' check to see if it's time to move the Projectile
    If GetTickCount > TempPlayer(Index).ProjecTile(PlayerProjectile).TravelTime Then
        With TempPlayer(Index).ProjecTile(PlayerProjectile)
            ' set next travel time and the current position and then set the actual direction based on RMXP arrow tiles.
            Select Case .Direction
                ' down
                Case DIR_DOWN
    If isDirBlocked(Map(GetPlayerMap(Index)).Tile(TempPlayer(Index).ProjecTile(PlayerProjectile).X, TempPlayer(Index).ProjecTile(PlayerProjectile).Y).DirBlock, DIR_DOWN - 1) Then
                        ClearProjectile Index, PlayerProjectile
                        Exit Sub
                    End If
                    .y = .y + 1
                    ' check if they reached maxrange
                    If .y = (GetPlayerY(Index) + .Range) + 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub
                ' up
                Case DIR_UP
    If isDirBlocked(Map(GetPlayerMap(Index)).Tile(TempPlayer(Index).ProjecTile(PlayerProjectile).X, TempPlayer(Index).ProjecTile(PlayerProjectile).Y).DirBlock, DIR_UP + 1) Then
                        ClearProjectile Index, PlayerProjectile
                        Exit Sub
                    End If
                    .y = .y - 1
                    ' check if they reached maxrange
                    If .y = (GetPlayerY(Index) - .Range) - 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub
                ' right
                Case DIR_RIGHT
    If isDirBlocked(Map(GetPlayerMap(Index)).Tile(TempPlayer(Index).ProjecTile(PlayerProjectile).X, TempPlayer(Index).ProjecTile(PlayerProjectile).Y).DirBlock, DIR_RIGHT + 1) Then
                        ClearProjectile Index, PlayerProjectile
                        Exit Sub
                    End If
                    .x = .x + 1
                    ' check if they reached max range
                    If .x = (GetPlayerX(Index) + .Range) + 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub
                ' left
                Case DIR_LEFT
    If isDirBlocked(Map(GetPlayerMap(Index)).Tile(TempPlayer(Index).ProjecTile(PlayerProjectile).X, TempPlayer(Index).ProjecTile(PlayerProjectile).Y).DirBlock, DIR_LEFT + 1) Then
                        ClearProjectile Index, PlayerProjectile
                        Exit Sub
                    End If
                    .x = .x - 1
                    ' check if they reached maxrange
                    If .x = (GetPlayerX(Index) - .Range) - 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub
            End Select
            .TravelTime = GetTickCount + .Speed
        End With
    End If

    x = TempPlayer(Index).ProjecTile(PlayerProjectile).x
    y = TempPlayer(Index).ProjecTile(PlayerProjectile).y

    ' check if left map
    If x > Map(GetPlayerMap(Index)).MaxX Or y > Map(GetPlayerMap(Index)).MaxY Or x < 0 Or y < 0 Then
        ClearProjectile Index, PlayerProjectile
        Exit Sub
    End If

    ' check if hit player
    For i = 1 To Player_HighIndex
        ' make sure they're actually playing
        If IsPlaying(i) Then
            ' check coordinates
            If x = Player(i).x And y = GetPlayerY(i) Then
                ' make sure it's not the attacker
                If Not x = Player(Index).x Or Not y = GetPlayerY(Index) Then
                    ' check if player can attack
                    If CanPlayerAttackPlayer(Index, i, False, True) = True Then
                        ' attack the player and kill the project tile
                        PlayerAttackPlayer Index, i, TempPlayer(Index).ProjecTile(PlayerProjectile).Damage
                        ClearProjectile Index, PlayerProjectile
                        Exit Sub
                    Else
                        ClearProjectile Index, PlayerProjectile
                        Exit Sub
                    End If
                End If
            End If
        End If
    Next

    ' check for npc hit
    For i = 1 To MAX_MAP_NPCS
        If x = MapNpc(GetPlayerMap(Index)).Npc(i).x And y = MapNpc(GetPlayerMap(Index)).Npc(i).y Then
            ' they're hit, remove it and deal that damage ;)
            If CanPlayerAttackNpc(Index, i, True) Then
                PlayerAttackNpc Index, i, TempPlayer(Index).ProjecTile(PlayerProjectile).Damage
                ClearProjectile Index, PlayerProjectile
                Exit Sub
            Else
                ClearProjectile Index, PlayerProjectile
                Exit Sub
            End If
        End If
    Next

    ' hit a block
    If Map(GetPlayerMap(Index)).Tile(X, Y).Type = TILE_TYPE_BLOCKED Or Map(GetPlayerMap(Index)).Tile(X, Y).Type = TILE_TYPE_RESOURCE Then
        ' hit a block, clear it.
        ClearProjectile Index, PlayerProjectile
        Exit Sub
    End If

End Sub
```
**Client side**

Replace **BltProjectile** with this:
```
' player Projectiles
Public Sub BltProjectile(ByVal Index As Long, ByVal PlayerProjectile As Long)
Dim x As Long, y As Long, PicNum As Long, i As Long
Dim rec As DxVBLib.RECT

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    ' check for subscript error
    If Index < 1 Or PlayerProjectile < 1 Or PlayerProjectile > MAX_PLAYER_PROJECTILES Then Exit Sub

    ' check to see if it's time to move the Projectile
    If GetTickCount > Player(Index).ProjecTile(PlayerProjectile).TravelTime Then
        With Player(Index).ProjecTile(PlayerProjectile)
            ' set next travel time and the current position and then set the actual direction based on RMXP arrow tiles.
            Select Case .Direction
                ' down
                Case 0
    If isDirBlocked(Map.Tile(Player(Index).ProjecTile(PlayerProjectile).x, Player(Index).ProjecTile(PlayerProjectile).y).DirBlock, DIR_DOWN + 1) Then
                        ClearProjectile Index, PlayerProjectile
                        Exit Sub
                    End If
                    .y = .y + 1
                    ' check if they reached maxrange
                    If .y = (GetPlayerY(Index) + .Range) + 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub
                ' up
                Case 1
    If isDirBlocked(Map.Tile(Player(Index).ProjecTile(PlayerProjectile).x, Player(Index).ProjecTile(PlayerProjectile).y).DirBlock, DIR_UP + 1) Then
                        ClearProjectile Index, PlayerProjectile
                        Exit Sub
                    End If
                    .y = .y - 1
                    ' check if they reached maxrange
                    If .y = (GetPlayerY(Index) - .Range) - 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub
                ' right
                Case 2
    If isDirBlocked(Map.Tile(Player(Index).ProjecTile(PlayerProjectile).x, Player(Index).ProjecTile(PlayerProjectile).y).DirBlock, DIR_RIGHT + 1) Then
                        ClearProjectile Index, PlayerProjectile
                        Exit Sub
                    End If
                    .x = .x + 1
                    ' check if they reached max range
                    If .x = (GetPlayerX(Index) + .Range) + 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub
                ' left
                Case 3
    If isDirBlocked(Map.Tile(Player(Index).ProjecTile(PlayerProjectile).x, Player(Index).ProjecTile(PlayerProjectile).y).DirBlock, DIR_LEFT + 1) Then
                        ClearProjectile Index, PlayerProjectile
                        Exit Sub
                    End If
                    .x = .x - 1
                    ' check if they reached maxrange
                    If .x = (GetPlayerX(Index) - .Range) - 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub
            End Select
            .TravelTime = GetTickCount + .Speed
        End With
    End If

    ' set the x, y & pic values for future reference
    x = Player(Index).ProjecTile(PlayerProjectile).x
    y = Player(Index).ProjecTile(PlayerProjectile).y
    PicNum = Player(Index).ProjecTile(PlayerProjectile).Pic

    ' check if left map
    If x > Map.MaxX Or y > Map.MaxY Or x < 0 Or y < 0 Then
        ClearProjectile Index, PlayerProjectile
        Exit Sub
    End If

    ' check if we hit a block
    If Map.Tile(x, y).Type = TILE_TYPE_BLOCKED Or Map.Tile(x, y).Type = TILE_TYPE_RESOURCE Then
        ClearProjectile Index, PlayerProjectile
        Exit Sub
    End If

    ' check for player hit
    For i = 1 To Player_HighIndex
        If x = GetPlayerX(i) And y = GetPlayerY(i) Then
            ' they're hit, remove it
            If Not x = Player(MyIndex).x Or Not y = GetPlayerY(MyIndex) Then
                ClearProjectile Index, PlayerProjectile
                Exit Sub
            End If
        End If
    Next

    ' check for npc hit
    For i = 1 To MAX_MAP_NPCS
        If x = MapNpc(i).x And y = MapNpc(i).y Then
            ' they're hit, remove it
            ClearProjectile Index, PlayerProjectile
            Exit Sub
        End If
    Next

    ' if projectile is not loaded, load it, female dog.
    If DDS_Projectile(PicNum) Is Nothing Then
        Call InitDDSurf("projectiles\" & PicNum, DDSD_Projectile(PicNum), DDS_Projectile(PicNum))
    End If

    ' get positioning in the texture
    With rec
        .top = 0
        .Bottom = SIZE_Y
        .Left = Player(Index).ProjecTile(PlayerProjectile).Direction * SIZE_X
        .Right = .Left + SIZE_X
    End With

    ' blt the projectile
    Call Engine_BltFast(ConvertMapX(x * PIC_X), ConvertMapY(y * PIC_Y), DDS_Projectile(PicNum), rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "BltProjectile", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...