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

Yep i got a label called lblProjectilePic

I make a copy of all my files and imported the uploaded form work and it works fine , so i tried to find out what was different but i cant seem to find a single thing that the uploaded form work has that i dont
I havent lost any other work by using the uploaded form work , im just kinda noobish at vb6 still and would like to know what causes this kinda problem
Link to comment
Share on other sites

  • 2 weeks later...
Great work!
~~The only problem I see is that players can attack eachother even within a safe zone. :S~~

EDIT: Lol nvm what I just said, I got it fixed now. ^^
Also its a shame that you can't hear the sounds when you shoot at a player, or a firing sound when you press ctrl, Ah wellz.. :)
Link to comment
Share on other sites

a easy way would be to put a animation with just sound and no animation, then set that animation to the weapon, this would give you sound when you are attacking something at least with the bow.
Link to comment
Share on other sites

  • 3 weeks later...
This is a nice source edit! Pretty useful!…
Yet I have a one question...
How can you make the arrows/projectiles stop when it hits a resource?

    -Kindly,
      Night~
Link to comment
Share on other sites

~~can someone iluminate me with their wisdom and tell me where is Sub Main? coz i can't find it in my src folder

Edit: found it in modGeneral, hope it is that

Re-edit: In modDirectDraw7 insert:
```
' 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
                    .y = .y + 1
                    ' check if they reached maxrange
                    If .y = (GetPlayerY(Index) + .Range) + 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub
                ' up
                Case 1
                    .y = .y - 1
                    ' check if they reached maxrange
                    If .y = (GetPlayerY(Index) - .Range) - 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub
                ' right
                Case 2
                    .x = .x + 1
                    ' check if they reached max range
                    If .x = (GetPlayerX(Index) + .Range) + 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub
                ' left
                Case 3
                    .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 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
```

~~i can place that anywhere i want inside modDirectDraw7?~~
Final edit: Could someone tell me if anyone had uploaded the client with this modification and that works? i made all the process and i can't use them…~~
Link to comment
Share on other sites

  • 2 weeks later...
EDIT: NVM there was a logic error in my canPlayerAttackNpc

Ok what is the line needed to keep you from killing friendly npcs with projectiles?

Because I can still kill friendly npcs is there a logic mistake in my sub?

```
Public Sub PlayerAttackNpc(ByVal attacker As Long, ByVal MapNpcNum As Long, ByVal Damage As Long, Optional ByVal SpellNum As Long, Optional ByVal overTime As Boolean = False)
    Dim Name As String
    Dim exp As Long
    Dim n As Long
    Dim i As Long
    Dim STR As Long
    Dim DEF As Long
    Dim mapnum As Long
    Dim npcNum As Long
    Dim Buffer As clsBuffer

    ' Check for subscript out of range
    If IsPlaying(attacker) = False Or MapNpcNum <= 0 Or MapNpcNum > MAX_MAP_NPCS Or Damage < 0 Then
        Exit Sub
    End If

    mapnum = GetPlayerMap(attacker)
    npcNum = MapNpc(mapnum).NPC(MapNpcNum).Num
        If npcNum < 1 Then Exit Sub
    Name = Trim$(NPC(npcNum).Name)

    ' Check for weapon
    n = 0

    If GetPlayerEquipment(attacker, Weapon) > 0 Then
        n = GetPlayerEquipment(attacker, Weapon)
    End If

    ' set the regen timer
    TempPlayer(attacker).stopRegen = True
    TempPlayer(attacker).stopRegenTimer = GetTickCount

    If Damage >= MapNpc(mapnum).NPC(MapNpcNum).Vital(Vitals.HP) Then

        SendActionMsg GetPlayerMap(attacker), "-" & MapNpc(mapnum).NPC(MapNpcNum).Vital(Vitals.HP), BrightRed, 1, (MapNpc(mapnum).NPC(MapNpcNum).x * 32), (MapNpc(mapnum).NPC(MapNpcNum).y * 32)
        SendBlood GetPlayerMap(attacker), MapNpc(mapnum).NPC(MapNpcNum).x, MapNpc(mapnum).NPC(MapNpcNum).y

        ' send the sound
        If SpellNum > 0 Then SendMapSound attacker, MapNpc(mapnum).NPC(MapNpcNum).x, MapNpc(mapnum).NPC(MapNpcNum).y, SoundEntity.seSpell, SpellNum

        ' send animation
        If n > 0 Then
            If Not overTime Then
                If SpellNum = 0 Then Call SendAnimation(mapnum, Item(GetPlayerEquipment(attacker, Weapon)).Animation, MapNpc(mapnum).NPC(MapNpcNum).x, MapNpc(mapnum).NPC(MapNpcNum).y)
            End If
        End If

        ' Calculate exp to give attacker
        exp = NPC(npcNum).exp

        ' Make sure we dont get less then 0
        If exp < 0 Then
            exp = 1
        End If

        ' in party?
        If TempPlayer(attacker).inParty > 0 Then
            ' pass through party sharing function
            Party_ShareExp TempPlayer(attacker).inParty, exp, attacker
        Else
            ' no party - keep exp for self
            GivePlayerEXP attacker, exp
        End If

        'Drop the goods if they get it
        For n = 1 To MAX_NPC_DROPS
        If NPC(npcNum).DropItem(n) = 0 Then Exit For
        If Rnd <= NPC(npcNum).DropChance(n) Then
        Call SpawnItem(NPC(npcNum).DropItem(n), NPC(npcNum).DropItemValue(n), mapnum, MapNpc(mapnum).NPC(MapNpcNum).x, MapNpc(mapnum).NPC(MapNpcNum).y)
        End If
        Next

        ' Now set HP to 0 so we know to actually kill them in the server loop (this prevents subscript out of range)
        MapNpc(mapnum).NPC(MapNpcNum).Num = 0
        MapNpc(mapnum).NPC(MapNpcNum).SpawnWait = GetTickCount
        MapNpc(mapnum).NPC(MapNpcNum).Vital(Vitals.HP) = 0

        ' clear DoTs and HoTs
        For i = 1 To MAX_DOTS
            With MapNpc(mapnum).NPC(MapNpcNum).DoT(i)
                .Spell = 0
                .Timer = 0
                .Caster = 0
                .StartTime = 0
                .Used = False
            End With

            With MapNpc(mapnum).NPC(MapNpcNum).HoT(i)
                .Spell = 0
                .Timer = 0
                .Caster = 0
                .StartTime = 0
                .Used = False
            End With
        Next
        Call CheckTasks(attacker, QUEST_TYPE_GOSLAY, npcNum)
        ' send death to the map
        Set Buffer = New clsBuffer
        Buffer.WriteLong SNpcDead
        Buffer.WriteLong MapNpcNum
        SendDataToMap mapnum, Buffer.ToArray()
        Set Buffer = Nothing

        'Loop through entire map and purge NPC from targets
        For i = 1 To Player_HighIndex
            If IsPlaying(i) And IsConnected(i) Then
                If Player(i).Map = mapnum Then
                    If TempPlayer(i).targetType = TARGET_TYPE_NPC Then
                        If TempPlayer(i).target = MapNpcNum Then
                            TempPlayer(i).target = 0
                            TempPlayer(i).targetType = TARGET_TYPE_NONE
                            SendTarget i
                        End If
                    End If
                End If
            End If
        Next
    Else
        ' NPC not dead, just do the damage
        MapNpc(mapnum).NPC(MapNpcNum).Vital(Vitals.HP) = MapNpc(mapnum).NPC(MapNpcNum).Vital(Vitals.HP) - Damage

        ' Check for a weapon and say damage
        SendActionMsg mapnum, "-" & Damage, BrightRed, 1, (MapNpc(mapnum).NPC(MapNpcNum).x * 32), (MapNpc(mapnum).NPC(MapNpcNum).y * 32)
        SendBlood GetPlayerMap(attacker), MapNpc(mapnum).NPC(MapNpcNum).x, MapNpc(mapnum).NPC(MapNpcNum).y

        ' send the sound
        If SpellNum > 0 Then SendMapSound attacker, MapNpc(mapnum).NPC(MapNpcNum).x, MapNpc(mapnum).NPC(MapNpcNum).y, SoundEntity.seSpell, SpellNum

        ' send animation
        If n > 0 Then
            If Not overTime Then
                If SpellNum = 0 Then Call SendAnimation(mapnum, Item(GetPlayerEquipment(attacker, Weapon)).Animation, 0, 0, TARGET_TYPE_NPC, MapNpcNum)
            End If
        End If

        ' Set the NPC target to the player
        MapNpc(mapnum).NPC(MapNpcNum).targetType = 1 ' player
        MapNpc(mapnum).NPC(MapNpcNum).target = attacker

        ' Now check for guard ai and if so have all onmap guards come after'm
        If NPC(MapNpc(mapnum).NPC(MapNpcNum).Num).Behaviour = NPC_BEHAVIOUR_GUARD Then
            For i = 1 To MAX_MAP_NPCS
                If MapNpc(mapnum).NPC(i).Num = MapNpc(mapnum).NPC(MapNpcNum).Num Then
                    MapNpc(mapnum).NPC(i).target = attacker
                    MapNpc(mapnum).NPC(i).targetType = 1 ' player
                End If
            Next
        End If

        ' set the regen timer
        MapNpc(mapnum).NPC(MapNpcNum).stopRegen = True
        MapNpc(mapnum).NPC(MapNpcNum).stopRegenTimer = GetTickCount

        ' if stunning spell, stun the npc
        If SpellNum > 0 Then
            If Spell(SpellNum).StunDuration > 0 Then StunNPC MapNpcNum, mapnum, SpellNum
            ' DoT
            If Spell(SpellNum).Duration > 0 Then
                AddDoT_Npc mapnum, MapNpcNum, SpellNum, attacker
            End If
        End If

        SendMapNpcVitals mapnum, MapNpcNum
    End If

    If SpellNum = 0 Then
        ' Reset attack timer
        TempPlayer(attacker).AttackTimer = GetTickCount
    End If
End Sub
```
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
Whenever I copy and paste code my paste in vb6 does not keep the formatting. I have to manually go in and ad spaces and tabs.

Is there some way of pasting the code and maintaining the codes format?

Thanks

example:

' player ProjectilesPublic Sub BltProjectile(ByVal Index As Long, ByVal PlayerProjectile As Long)Dim x As Long, y As Long, PicNum As Long, i As LongDim 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                    .y = .y + 1                    ' check if they reached maxrange                    If .y = (GetPlayerY(Index) + .Range) + 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub                ' up                Case 1                    .y = .y - 1                    ' check if they reached maxrange                    If .y = (GetPlayerY(Index) - .Range) - 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub                ' right                Case 2                    .x = .x + 1                    ' check if they reached max range                    If .x = (GetPlayerX(Index) + .Range) + 1 Then ClearProjectile Index, PlayerProjectile: Exit Sub                ' left                Case 3                    .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 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 Suberrorhandler:    HandleError "BltProjectile", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContext    Err.Clear    Exit SubEnd Sub
Link to comment
Share on other sites

@Captain:

> Your friend has done it wrong. It's smooth as hell for me.

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_
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...