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

(ALL VERSIONS)Linear Spells fix


tslusny
 Share

Recommended Posts

Tutorial required: [Linear Spells (made by Draconix)](http://www.touchofdeathforums.com/smf2/index.php/topic,73750.0.html)

SERVER SIDE:
Replace **Sub FireProjectile** with this:
```
Public Sub FireProjectile(ByVal Index As Long, ByVal Dir As Long, ByVal Damage As Long, ByVal range As Long, Optional ByVal SpellNum As Long, Optional ByVal itemnum As Long)
Dim i As Long
Dim r As Long
Dim MapNum As Long
Dim canShoot As Boolean
Dim DidCast As Boolean

    MapNum = GetPlayerMap(Index)

    If Damage = 0 Then
        Damage = GetPlayerDamage(Index)
    End If

    canShoot = False
    DidCast = False

    For r = 1 To range
        Select Case Dir
            Case DIR_UP
                If GetPlayerY(Index) - r < 0 Then Exit Sub
                If Map(MapNum).Tile(GetPlayerX(Index), GetPlayerY(Index) - r).Type = TILE_TYPE_BLOCKED Or Map(MapNum).Tile(GetPlayerX(Index), GetPlayerY(Index) - r).Type = TILE_TYPE_RESOURCE Then
                    If SpellNum > 0 Then
                        SendAnimation MapNum, Spell(Player(Index).Spell(SpellNum)).SpellAnim, GetPlayerX(Index), GetPlayerY(Index) - r
                        DidCast = True
                    Else
                        SendAnimation MapNum, Item(GetPlayerEquipment(Index, Weapon)).Animation, GetPlayerX(Index), GetPlayerY(Index) - r
                        Exit Sub
                    End If
                End If
            Case DIR_DOWN
                If GetPlayerY(Index) + r > Map(MapNum).MaxY Then Exit Sub
                If Map(MapNum).Tile(GetPlayerX(Index), GetPlayerY(Index) + r).Type = TILE_TYPE_BLOCKED Or Map(MapNum).Tile(GetPlayerX(Index), GetPlayerY(Index) + r).Type = TILE_TYPE_RESOURCE Then
                    If SpellNum > 0 Then
                            SendAnimation MapNum, Spell(Player(Index).Spell(SpellNum)).SpellAnim, GetPlayerX(Index), GetPlayerY(Index) + r
                            DidCast = True
                        Else
                            SendAnimation MapNum, Item(GetPlayerEquipment(Index, Weapon)).Animation, GetPlayerX(Index), GetPlayerY(Index) - r
                            Exit Sub
                        End If
                    End If
            Case DIR_LEFT
                If GetPlayerX(Index) - r < 0 Then Exit Sub
                If Map(MapNum).Tile(GetPlayerX(Index) - r, GetPlayerY(Index)).Type = TILE_TYPE_BLOCKED Or Map(MapNum).Tile(GetPlayerX(Index) - r, GetPlayerY(Index)).Type = TILE_TYPE_RESOURCE Then
                    If SpellNum > 0 Then
                            SendAnimation MapNum, Spell(Player(Index).Spell(SpellNum)).SpellAnim, GetPlayerX(Index) - r, GetPlayerY(Index)
                            DidCast = True
                        Else
                            SendAnimation MapNum, Item(GetPlayerEquipment(Index, Weapon)).Animation, GetPlayerX(Index), GetPlayerY(Index) - r
                            Exit Sub
                        End If
                    End If
            Case DIR_RIGHT
                If GetPlayerX(Index) + r > Map(MapNum).MaxX Then Exit Sub
                If Map(MapNum).Tile(GetPlayerX(Index) + r, GetPlayerY(Index)).Type = TILE_TYPE_BLOCKED Or Map(MapNum).Tile(GetPlayerX(Index) + r, GetPlayerY(Index)).Type = TILE_TYPE_RESOURCE Then
                    If SpellNum > 0 Then
                            SendAnimation MapNum, Spell(Player(Index).Spell(SpellNum)).SpellAnim, GetPlayerX(Index) + r, GetPlayerY(Index)
                            DidCast = True
                        Else
                            SendAnimation MapNum, Item(GetPlayerEquipment(Index, Weapon)).Animation, GetPlayerX(Index), GetPlayerY(Index) - r
                            Exit Sub
                        End If
                    End If
        End Select

        If DidCast = True Then
            Call SetPlayerVital(Index, Vitals.MP, GetPlayerVital(Index, Vitals.MP) - Spell(Player(Index).Spell(SpellNum)).MPCost)
            Call SendVital(Index, Vitals.MP)

            TempPlayer(Index).SpellCD(Player(Index).Spell(SpellNum)) = GetTickCount + (Spell(Player(Index).Spell(SpellNum)).CDTime * 1000)
            Call SendCooldown(Index, SpellNum)
            SendActionMsg MapNum, Trim$(Spell(Player(Index).Spell(SpellNum)).Name) & "!", BrightRed, ACTIONMSG_SCROLL, GetPlayerX(Index) * 32, GetPlayerY(Index) * 32
            Exit Sub
        End If

        For i = 1 To MAX_MAP_NPCS

            If CanPlayerAttackNpc(Index, i, True) Then

            If Dir = DIR_UP Then
                If GetPlayerX(Index) = MapNpc(MapNum).Npc(i).x And GetPlayerY(Index) - r = MapNpc(MapNum).Npc(i).y Then
                    canShoot = True
                End If
            End If
            If Dir = DIR_DOWN Then
                If GetPlayerX(Index) = MapNpc(MapNum).Npc(i).x And GetPlayerY(Index) + r = MapNpc(MapNum).Npc(i).y Then
                    canShoot = True
                End If
            End If
            If Dir = DIR_LEFT Then
                If GetPlayerX(Index) - r = MapNpc(MapNum).Npc(i).x And GetPlayerY(Index) = MapNpc(MapNum).Npc(i).y Then
                    canShoot = True
                End If
            End If
            If Dir = DIR_RIGHT Then
                If GetPlayerX(Index) + r = MapNpc(MapNum).Npc(i).x And GetPlayerY(Index) = MapNpc(MapNum).Npc(i).y Then
                    canShoot = True
                End If
            End If

            If canShoot = True Then
                If SpellNum > 0 Then
                    CastSpell Index, SpellNum, i, TARGET_TYPE_NPC
                    Exit Sub
                Else
                    Call PlayerAttackNpc(Index, i, Damage)
                    Exit Sub
                End If
            End If

            End If

        Next

        For i = 1 To Player_HighIndex
            If i <> Index Then

            If CanPlayerAttackPlayer(Index, i, True) Then

            If Dir = DIR_UP Then
                If GetPlayerX(Index) = GetPlayerX(i) And GetPlayerY(Index) - r = GetPlayerY(i) Then
                    canShoot = True
                End If
            End If
            If Dir = DIR_DOWN Then
                If GetPlayerX(Index) = GetPlayerX(i) And GetPlayerY(Index) + r = GetPlayerY(i) Then
                    canShoot = True
                End If
            End If
            If Dir = DIR_LEFT Then
                If GetPlayerX(Index) - r = GetPlayerX(i) And GetPlayerY(Index) = GetPlayerY(i) Then
                    canShoot = True
                End If
            End If
            If Dir = DIR_RIGHT Then
                If GetPlayerX(Index) + r = GetPlayerX(i) And GetPlayerY(Index) = GetPlayerY(i) Then
                    canShoot = True
                End If
            End If

            If canShoot = True Then
                If SpellNum > 0 Then
                    CastSpell Index, SpellNum, i, TARGET_TYPE_PLAYER
                    Exit Sub
                Else
                    Call PlayerAttackPlayer(Index, i, Damage)
                    Exit Sub
                End If
            End If

            End If

            End If
        Next
    Next
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...