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

More Advanced/Accurate CastSpell Sub


varinyc
 Share

Recommended Posts

Adds Arena fixes to the spells, such as if one player is not on an arena tile while the other one is, or vice versa.

Adds guilds to the sub (for SUB-Spells of course)

Owners are excluded from all the checks (Perk I like, it can be removed)

The Area of Effect passes over targets not allowed to be hit, instead of ending the sub.

Damaging yourself is out, although not too difficult to put back in.

Healing monsters is out, but again can be put back in.

MP costs is an initial MP cost, then like 10% of the original cost for any target after #1 for Area of Effect.

I made this sub for me, I apologize if you liked some of the features i took out, you can change whatever though.

```
Sub CastSpell(ByVal index As Long, ByVal SpellSlot As Long)
    Dim SpellNum As Long, I As Long, n As Long, Damage As Long
    Dim Casted As Boolean
    Casted = False

    ' Prevent player from using spells if they have been script locked
    If Player(index).LockedSpells = True Then
        Exit Sub
    End If

    ' Prevent subscript out of range
    If SpellSlot <= 0 Or SpellSlot > MAX_PLAYER_SPELLS Then
        Exit Sub
    End If

    SpellNum = GetPlayerSpell(index, SpellSlot)

    ' Make sure player has the spell
    If Not HasSpell(index, SpellNum) Then
        Call BattleMsg(index, "You do not have this spell!", BRIGHTRED, 0)
        Exit Sub
    End If

    I = GetSpellReqLevel(SpellNum)

    ' Check if they have enough MP
    If GetPlayerMP(index) < Spell(SpellNum).MPCost Then
        Call BattleMsg(index, "Not enough mana!", BRIGHTRED, 0)
        Exit Sub
    End If

    ' Make sure they are the right level
    If I > GetPlayerLevel(index) Then
        Call BattleMsg(index, "You need to be " & I & "to cast this spell.", BRIGHTRED, 0)
        Exit Sub
    End If

    ' Check if timer is ok
    If GetTickCount < Player(index).AttackTimer + 1000 Then
        Exit Sub
    End If

    ' Check if the spell is scripted and do that instead of a stat modification
    If Spell(SpellNum).Type = SPELL_TYPE_SCRIPTED Then

        MyScript.ExecuteStatement "Scripts\Main.ess", "ScriptedSpell " & index & "," & Spell(SpellNum).Data1

        Exit Sub
    End If

    Dim x As Long, y As Long
    Dim affected As String

    If Spell(SpellNum).AE = 1 Then
        For y = GetPlayerY(index) - Spell(SpellNum).Range To GetPlayerY(index) + Spell(SpellNum).Range
            For x = GetPlayerX(index) - Spell(SpellNum).Range To GetPlayerX(index) + Spell(SpellNum).Range
                n = -1
                For I = 1 To MAX_PLAYERS
                    If IsPlaying(I) = True Then
                        If GetPlayerMap(index) = GetPlayerMap(I) Then
                            If GetPlayerX(I) = x And GetPlayerY(I) = y Then
                                If I = index Then
                                    If Spell(SpellNum).Type = SPELL_TYPE_ADDHP Or Spell(SpellNum).Type = SPELL_TYPE_ADDMP Or Spell(SpellNum).Type = SPELL_TYPE_ADDSP Then
                                        Player(index).Target = I
                                        Player(index).TargetType = TARGET_TYPE_PLAYER
                                        n = Player(index).Target
                                    End If
                                Else
                                    If Spell(SpellNum).Type >= SPELL_TYPE_ADDHP And Spell(SpellNum).Type <= SPELL_TYPE_ADDSP Then
                                        If GetPlayerAccess(index) < 5 Then
                                            If GetPlayerHP(I) > 0 Then
                                                If (GetPlayerAccess(index) <= 1 And GetPlayerAccess(I) <= 1) Or (GetPlayerAccess(index) > 1 And GetPlayerAccess(I) > 1) Then
                                                    If GetPlayerAccess(n) <> 5 Then
                                                        If (Map(GetPlayerMap(I)).Tile(GetPlayerX(I), GetPlayerY(I)).Type = TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_ARENA) Or (Map(GetPlayerMap(I)).Tile(GetPlayerX(I), GetPlayerY(I)).Type <> TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type <> TILE_TYPE_ARENA) Then
                                                            Player(index).Target = I
                                                            Player(index).TargetType = TARGET_TYPE_PLAYER
                                                            n = Player(index).Target

                                                            Call SetPlayerMP(index, GetPlayerMP(index) - (Spell(SpellNum).MPCost / 10))
                                                            Call SendMP(index)
                                                        End If
                                                    End If
                                                End If
                                            End If
                                        Else
                                            Player(index).Target = I
                                            Player(index).TargetType = TARGET_TYPE_PLAYER
                                            n = Player(index).Target
                                        End If
                                    ElseIf Spell(SpellNum).Type >= SPELL_TYPE_SUBHP And Spell(SpellNum).Type <= SPELL_TYPE_SUBSP Then
                                        If GetPlayerAccess(index) < 5 Then
                                            If GetPlayerHP(I) > 0 Then
                                                If Map(GetPlayerMap(index)).Moral = MAP_MORAL_NONE Or Map(GetPlayerMap(index)).Moral = MAP_MORAL_NO_PENALTY Or GetPlayerPK(n) = YES Then
                                                    If (GetPlayerAccess(index) <= 1 And GetPlayerAccess(I) <= 1) Or (GetPlayerAccess(index) > 1 And GetPlayerAccess(I) > 1) Then
                                                        If GetPlayerLevel(index) >= 5 Then
                                                            If GetPlayerLevel(I) >= 5 Then
                                                                If GetPlayerAccess(I) <> 5 Then
                                                                    If LenB(GetPlayerGuild(index)) <> 0 Then
                                                                        If Trim$(GetPlayerGuild(index)) <> Trim$(GetPlayerGuild(I)) Then
                                                                            If (Map(GetPlayerMap(I)).Tile(GetPlayerX(I), GetPlayerY(I)).Type = TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_ARENA) Or (Map(GetPlayerMap(I)).Tile(GetPlayerX(I), GetPlayerY(I)).Type <> TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type <> TILE_TYPE_ARENA) Then
                                                                                Player(index).Target = I
                                                                                Player(index).TargetType = TARGET_TYPE_PLAYER
                                                                                n = Player(index).Target

                                                                                Call SetPlayerMP(index, GetPlayerMP(index) - (Spell(SpellNum).MPCost / 10))
                                                                                Call SendMP(index)
                                                                            End If
                                                                        End If
                                                                    Else
                                                                        If (Map(GetPlayerMap(I)).Tile(GetPlayerX(I), GetPlayerY(I)).Type = TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_ARENA) Or (Map(GetPlayerMap(I)).Tile(GetPlayerX(I), GetPlayerY(I)).Type <> TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type <> TILE_TYPE_ARENA) Then
                                                                            Player(index).Target = I
                                                                            Player(index).TargetType = TARGET_TYPE_PLAYER
                                                                            n = Player(index).Target

                                                                            Call SetPlayerMP(index, GetPlayerMP(index) - (Spell(SpellNum).MPCost / 10))
                                                                            Call SendMP(index)
                                                                        End If
                                                                    End If
                                                                End If
                                                            End If
                                                        End If
                                                    End If
                                                End If
                                            End If
                                        Else
                                            Player(index).Target = I
                                            Player(index).TargetType = TARGET_TYPE_PLAYER
                                            n = Player(index).Target

                                            Call SetPlayerMP(index, GetPlayerMP(index) - (Spell(SpellNum).MPCost / 10))
                                            Call SendMP(index)
                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If
                Next I

                For I = 1 To MAX_MAP_NPCS
                    If MapNPC(GetPlayerMap(index), I).num > 0 Then
                        If NPC(MapNPC(GetPlayerMap(index), I).num).Behavior <> NPC_BEHAVIOR_FRIENDLY And NPC(MapNPC(GetPlayerMap(index), I).num).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then
                            If MapNPC(GetPlayerMap(index), I).x = x And MapNPC(GetPlayerMap(index), I).y = y Then
                                Player(index).Target = I
                                Player(index).TargetType = TARGET_TYPE_NPC
                                n = Player(index).Target

                                Call SetPlayerMP(index, GetPlayerMP(index) - (Spell(SpellNum).MPCost / 10))
                                Call SendMP(index)
                            End If
                        End If
                    End If
                Next I

                Casted = False
                If n > 0 Then
                    If Player(index).TargetType = TARGET_TYPE_PLAYER Then
                        If IsPlaying(n) Then
                            If n = index Then
                                Select Case Spell(SpellNum).Type
                                    Case SPELL_TYPE_ADDHP
                                        Call SetPlayerHP(n, GetPlayerHP(n) + Spell(SpellNum).Data1)
                                        Call SendHP(n)

                                    Case SPELL_TYPE_ADDMP
                                        Call SetPlayerMP(n, GetPlayerMP(n) + Spell(SpellNum).Data1)
                                        Call SendMP(n)

                                    Case SPELL_TYPE_ADDSP
                                        Call SetPlayerSP(n, GetPlayerSP(n) + Spell(SpellNum).Data1)
                                        Call SendSP(n)
                                End Select
                                Casted = True

                            ElseIf n <> index Then
                                Player(index).TargetType = TARGET_TYPE_PLAYER
                                If Spell(SpellNum).Type >= SPELL_TYPE_SUBHP And Spell(SpellNum).Type <= SPELL_TYPE_SUBSP Then

                                    Select Case Spell(SpellNum).Type
                                        Case SPELL_TYPE_SUBHP

                                            Damage = (Int(GetPlayerMAGI(index) / 4) + Spell(SpellNum).Data1) - GetPlayerProtection(n)
                                            If Damage > 0 Then
                                                Call AttackPlayer(index, n, Damage)
                                            Else
                                                Call BattleMsg(index, "The spell was to weak to hurt " & GetPlayerName(n) & "!", BRIGHTRED, 0)
                                            End If

                                        Case SPELL_TYPE_SUBMP
                                            Call SetPlayerMP(n, GetPlayerMP(n) - Spell(SpellNum).Data1)
                                            Call SendMP(n)

                                        Case SPELL_TYPE_SUBSP
                                            Call SetPlayerSP(n, GetPlayerSP(n) - Spell(SpellNum).Data1)
                                            Call SendSP(n)
                                    End Select

                                    Casted = True

                                ElseIf Spell(SpellNum).Type >= SPELL_TYPE_ADDHP And Spell(SpellNum).Type <= SPELL_TYPE_ADDSP Then

                                    Select Case Spell(SpellNum).Type
                                        Case SPELL_TYPE_ADDHP
                                            Call SetPlayerHP(n, GetPlayerHP(n) + Spell(SpellNum).Data1)
                                            Call SendHP(n)
                                        Case SPELL_TYPE_ADDMP
                                            Call SetPlayerMP(n, GetPlayerMP(n) + Spell(SpellNum).Data1)
                                            Call SendMP(n)
                                        Case SPELL_TYPE_ADDSP
                                            Call SetPlayerSP(n, GetPlayerSP(n) + Spell(SpellNum).Data1)
                                            Call SendSP(n)
                                    End Select

                                    Casted = True

                                End If
                            End If
                        Else
                            Call BattleMsg(index, "Could not cast spell!", BRIGHTRED, 0)
                        End If
                    Else
                        Player(index).TargetType = TARGET_TYPE_NPC
                        If NPC(MapNPC(GetPlayerMap(index), n).num).Behavior <> NPC_BEHAVIOR_FRIENDLY And NPC(MapNPC(GetPlayerMap(index), n).num).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then
                            If Spell(SpellNum).Type >= SPELL_TYPE_SUBHP And Spell(SpellNum).Type <= SPELL_TYPE_SUBSP Then
                                Select Case Spell(SpellNum).Type

                                    Case SPELL_TYPE_SUBHP
                                        Damage = (Int(GetPlayerMAGI(index) / 4) + Spell(SpellNum).Data1) - Int(NPC(MapNPC(GetPlayerMap(index), n).num).DEF / 2)

                                        If Damage > 0 Then
                                            If Spell(SpellNum).Element <> 0 And NPC(MapNPC(GetPlayerMap(index), n).num).Element <> 0 Then
                                                If Element(Spell(SpellNum).Element).Strong = NPC(MapNPC(GetPlayerMap(index), n).num).Element Or Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Weak = Spell(SpellNum).Element Then
                                                    Call BattleMsg(index, "A deadly mix of elements harm the " & Trim$(NPC(MapNPC(GetPlayerMap(index), n).num).Name) & "!", BLUE, 0)
                                                    Damage = Int(Damage * 1.25)
                                                    If Element(Spell(SpellNum).Element).Strong = NPC(MapNPC(GetPlayerMap(index), n).num).Element And Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Weak = Spell(SpellNum).Element Then
                                                        Damage = Int(Damage * 1.2)
                                                    End If
                                                End If

                                                If Element(Spell(SpellNum).Element).Weak = NPC(MapNPC(GetPlayerMap(index), n).num).Element Or Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Strong = Spell(SpellNum).Element Then
                                                    Call BattleMsg(index, "The " & Trim$(NPC(MapNPC(GetPlayerMap(index), n).num).Name) & " absorbs much of the elemental damage!", RED, 0)
                                                    Damage = Int(Damage * 0.75)
                                                    If Element(Spell(SpellNum).Element).Weak = NPC(MapNPC(GetPlayerMap(index), n).num).Element And Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Strong = Spell(SpellNum).Element Then
                                                        Damage = Int(Damage * (2 / 3))
                                                    End If
                                                End If
                                            End If
                                            Call AttackNpc(index, n, Damage)
                                        Else
                                            Call BattleMsg(index, "The spell was to weak to hurt " & Trim$(NPC(MapNPC(GetPlayerMap(index), n).num).Name) & "!", BRIGHTRED, 0)
                                        End If

                                    Case SPELL_TYPE_SUBMP
                                        MapNPC(GetPlayerMap(index), n).MP = MapNPC(GetPlayerMap(index), n).MP - Spell(SpellNum).Data1

                                    Case SPELL_TYPE_SUBSP
                                        MapNPC(GetPlayerMap(index), n).SP = MapNPC(GetPlayerMap(index), n).SP - Spell(SpellNum).Data1
                                End Select

                                Casted = True
                            End If
                        Else
                            Call BattleMsg(index, "Could not cast spell!", BRIGHTRED, 0)
                        End If
                    End If
                End If
                If Casted = True Then
                    Call SendDataToMap(GetPlayerMap(index), "spellanim" & SEP_CHAR & SpellNum & SEP_CHAR & Spell(SpellNum).SpellAnim & SEP_CHAR & Spell(SpellNum).SpellTime & SEP_CHAR & Spell(SpellNum).SpellDone & SEP_CHAR & index & SEP_CHAR & Player(index).TargetType & SEP_CHAR & Player(index).Target & SEP_CHAR & Player(index).CastedSpell & SEP_CHAR & Spell(SpellNum).Big & END_CHAR)
                    Call SendDataToMap(GetPlayerMap(index), "sound" & SEP_CHAR & "magic" & SEP_CHAR & Spell(SpellNum).Sound & END_CHAR)
                End If
            Next x
        Next y

        Call SetPlayerMP(index, GetPlayerMP(index) - Spell(SpellNum).MPCost)
        Call SendMP(index)
    Else
        n = Player(index).Target
        If Player(index).TargetType = TARGET_TYPE_PLAYER Then
            If IsPlaying(n) Then

                Player(index).TargetType = TARGET_TYPE_PLAYER

                If Spell(SpellNum).Type >= SPELL_TYPE_SUBHP And Spell(SpellNum).Type <= SPELL_TYPE_SUBSP Then
                    If GetPlayerAccess(index) < 5 Then
                        If GetPlayerMap(index) <> GetPlayerMap(n) Then
                            Call PlayerMsg(index, "You must be on the same map as your target!", BRIGHTRED)
                            Exit Sub
                        End If

                        If index = n Then
                            Call PlayerMsg(index, "You cannot attack yourself!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerHP(n) <= 0 Then
                            Call PlayerMsg(index, "This player is already void of life!", BRIGHTRED)
                            Exit Sub
                        End If

                        If Map(GetPlayerMap(index)).Moral <> MAP_MORAL_NONE And Map(GetPlayerMap(index)).Moral <> MAP_MORAL_NO_PENALTY And GetPlayerPK(n) <> YES Then
                            Call PlayerMsg(index, "This is a safe zone!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerAccess(index) > 1 And GetPlayerAccess(n) <= 1 Then
                            Call PlayerMsg(index, "You cannot attack players!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerAccess(index) <= 1 And GetPlayerAccess(n) > 1 Then
                            Call PlayerMsg(index, "You cannot attack staff!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerLevel(index) < 5 Then
                            Call PlayerMsg(index, "You must be above level 5 to attack players!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerLevel(n) < 5 Then
                            Call PlayerMsg(index, "Your target must be above level 5!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerAccess(n) = 5 Then
                            Call PlayerMsg(index, "You cannot attack this person!", BRIGHTRED)
                            Exit Sub
                        End If

                        If Trim$(GetPlayerGuild(index)) <> vbNullString And GetPlayerGuild(n) <> vbNullString Then
                            If Trim$(GetPlayerGuild(index)) = Trim$(GetPlayerGuild(n)) Then
                                Call PlayerMsg(index, "You cannot attack a guild member!", BRIGHTRED)
                                Exit Sub
                            End If
                        End If

                        If Map(GetPlayerMap(n)).Tile(GetPlayerX(n), GetPlayerY(n)).Type = TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type <> TILE_TYPE_ARENA Then
                            Call PlayerMsg(index, "You must be in the Arena to attack this person!", BRIGHTRED)
                            Exit Sub
                        ElseIf Map(GetPlayerMap(n)).Tile(GetPlayerX(n), GetPlayerY(n)).Type <> TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_ARENA Then
                            Call PlayerMsg(index, "Your opponent must be in the Arena!", BRIGHTRED)
                            Exit Sub
                        End If
                    End If

                    Select Case Spell(SpellNum).Type
                        Case SPELL_TYPE_SUBHP

                            Damage = (Int(GetPlayerMAGI(index) / 4) + Spell(SpellNum).Data1) - GetPlayerProtection(n)
                            If Damage > 0 Then
                                Call AttackPlayer(index, n, Damage)
                            Else
                                Call BattleMsg(index, "The spell was to weak to hurt " & GetPlayerName(n) & "!", BRIGHTRED, 0)
                            End If

                        Case SPELL_TYPE_SUBMP
                            Call SetPlayerMP(n, GetPlayerMP(n) - Spell(SpellNum).Data1)
                            Call SendMP(n)

                        Case SPELL_TYPE_SUBSP
                            Call SetPlayerSP(n, GetPlayerSP(n) - Spell(SpellNum).Data1)
                            Call SendSP(n)
                    End Select

                    ' Take away the mana points
                    Call SetPlayerMP(index, GetPlayerMP(index) - Spell(SpellNum).MPCost)
                    Call SendMP(index)
                    Casted = True

                ElseIf Spell(SpellNum).Type >= SPELL_TYPE_ADDHP And Spell(SpellNum).Type <= SPELL_TYPE_ADDSP Then
                    If GetPlayerAccess(index) < 5 Then
                        If GetPlayerMap(index) <> GetPlayerMap(n) Then
                            Call PlayerMsg(index, "You must be on the same map as your target!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerHP(n) <= 0 Then
                            Call PlayerMsg(index, "This player is already void of life!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerAccess(index) > 1 And GetPlayerAccess(n) <= 1 Then
                            Call PlayerMsg(index, "You cannot heal players!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerAccess(index) <= 1 And GetPlayerAccess(n) > 1 Then
                            Call PlayerMsg(index, "You cannot heal staff!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerAccess(n) = 5 Then
                            Call PlayerMsg(index, "You cannot heal this person!", BRIGHTRED)
                            Exit Sub
                        End If

                        If Map(GetPlayerMap(n)).Tile(GetPlayerX(n), GetPlayerY(n)).Type = TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type <> TILE_TYPE_ARENA Then
                            Call PlayerMsg(index, "You must be in the Arena too!", BRIGHTRED)
                            Exit Sub
                        ElseIf Map(GetPlayerMap(n)).Tile(GetPlayerX(n), GetPlayerY(n)).Type <> TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_ARENA Then
                            Call PlayerMsg(index, "Your opponent must be in the Arena too!", BRIGHTRED)
                            Exit Sub
                        End If
                    End If

                    Select Case Spell(SpellNum).Type

                        Case SPELL_TYPE_ADDHP
                            Call SetPlayerHP(n, GetPlayerHP(n) + Spell(SpellNum).Data1)
                            Call SendHP(n)
                        Case SPELL_TYPE_ADDMP
                            Call SetPlayerMP(n, GetPlayerMP(n) + Spell(SpellNum).Data1)
                            Call SendMP(n)
                        Case SPELL_TYPE_ADDSP
                            Call SetPlayerSP(n, GetPlayerSP(n) + Spell(SpellNum).Data1)
                            Call SendSP(n)
                    End Select

                    ' Take away the mana points
                    Call SetPlayerMP(index, GetPlayerMP(index) - Spell(SpellNum).MPCost)
                    Call SendMP(index)
                    Casted = True
                End If
            Else
                Call PlayerMsg(index, "Cannot cast spell!", BRIGHTRED)
            End If
        Else
            n = Player(index).TargetNPC
            If CInt(Sqr((GetPlayerX(index) - MapNPC(GetPlayerMap(index), n).x) ^ 2 + ((GetPlayerY(index) - MapNPC(GetPlayerMap(index), n).y) ^ 2))) > Spell(SpellNum).Range Then
                Call BattleMsg(index, "You are too far away to hit the target.", BRIGHTRED, 0)
                Exit Sub
            End If

            Player(index).TargetType = TARGET_TYPE_NPC

            If NPC(MapNPC(GetPlayerMap(index), n).num).Behavior <> NPC_BEHAVIOR_FRIENDLY And NPC(MapNPC(GetPlayerMap(index), n).num).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then

                Select Case Spell(SpellNum).Type
                    Case SPELL_TYPE_SUBHP

                        Damage = (Int(GetPlayerMAGI(index) / 4) + Spell(SpellNum).Data1) - Int(NPC(MapNPC(GetPlayerMap(index), n).num).DEF / 2)
                        If Damage > 0 Then
                            If Spell(SpellNum).Element <> 0 And NPC(MapNPC(GetPlayerMap(index), n).num).Element <> 0 Then
                                If Element(Spell(SpellNum).Element).Strong = NPC(MapNPC(GetPlayerMap(index), n).num).Element Or Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Weak = Spell(SpellNum).Element Then
                                    Call BattleMsg(index, "A deadly mix of elements harm the " & Trim$(NPC(MapNPC(GetPlayerMap(index), n).num).Name) & "!", BLUE, 0)
                                    Damage = Int(Damage * 1.25)
                                    If Element(Spell(SpellNum).Element).Strong = NPC(MapNPC(GetPlayerMap(index), n).num).Element And Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Weak = Spell(SpellNum).Element Then
                                        Damage = Int(Damage * 1.2)
                                    End If
                                End If

                                If Element(Spell(SpellNum).Element).Weak = NPC(MapNPC(GetPlayerMap(index), n).num).Element Or Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Strong = Spell(SpellNum).Element Then
                                    Call BattleMsg(index, "The " & Tr
```
Link to comment
Share on other sites

Adds Arena fixes to the spells, such as if one player is not on an arena tile while the other one is, or vice versa.

Adds guilds to the sub (for SUB-Spells of course)

Owners are excluded from all the checks (Perk I like, it can be removed)

The Area of Effect passes over targets not allowed to be hit, instead of ending the sub.

Damaging yourself is out, although not too difficult to put back in.

Healing monsters is out, but again can be put back in.

MP costs is an initial MP cost, then like 10% of the original cost for any target after #1 for Area of Effect.

I made this sub for me, I apologize if you liked some of the features i took out, you can change whatever though.

```
Sub CastSpell(ByVal index As Long, ByVal SpellSlot As Long)
    Dim SpellNum As Long, I As Long, n As Long, Damage As Long
    Dim Casted As Boolean
    Casted = False

    ' Prevent player from using spells if they have been script locked
    If Player(index).LockedSpells = True Then
        Exit Sub
    End If

    ' Prevent subscript out of range
    If SpellSlot <= 0 Or SpellSlot > MAX_PLAYER_SPELLS Then
        Exit Sub
    End If

    SpellNum = GetPlayerSpell(index, SpellSlot)

    ' Make sure player has the spell
    If Not HasSpell(index, SpellNum) Then
        Call BattleMsg(index, "You do not have this spell!", BRIGHTRED, 0)
        Exit Sub
    End If

    I = GetSpellReqLevel(SpellNum)

    ' Check if they have enough MP
    If GetPlayerMP(index) < Spell(SpellNum).MPCost Then
        Call BattleMsg(index, "Not enough mana!", BRIGHTRED, 0)
        Exit Sub
    End If

    ' Make sure they are the right level
    If I > GetPlayerLevel(index) Then
        Call BattleMsg(index, "You need to be " & I & "to cast this spell.", BRIGHTRED, 0)
        Exit Sub
    End If

    ' Check if timer is ok
    If GetTickCount < Player(index).AttackTimer + 1000 Then
        Exit Sub
    End If

    ' Check if the spell is scripted and do that instead of a stat modification
    If Spell(SpellNum).Type = SPELL_TYPE_SCRIPTED Then

        MyScript.ExecuteStatement "Scripts\Main.ess", "ScriptedSpell " & index & "," & Spell(SpellNum).Data1

        Exit Sub
    End If

    Dim x As Long, y As Long
    Dim affected As String

    If Spell(SpellNum).AE = 1 Then
        For y = GetPlayerY(index) - Spell(SpellNum).Range To GetPlayerY(index) + Spell(SpellNum).Range
            For x = GetPlayerX(index) - Spell(SpellNum).Range To GetPlayerX(index) + Spell(SpellNum).Range
                n = -1
                For I = 1 To MAX_PLAYERS
                    If IsPlaying(I) = True Then
                        If GetPlayerMap(index) = GetPlayerMap(I) Then
                            If GetPlayerX(I) = x And GetPlayerY(I) = y Then
                                If I = index Then
                                    If Spell(SpellNum).Type = SPELL_TYPE_ADDHP Or Spell(SpellNum).Type = SPELL_TYPE_ADDMP Or Spell(SpellNum).Type = SPELL_TYPE_ADDSP Then
                                        Player(index).Target = I
                                        Player(index).TargetType = TARGET_TYPE_PLAYER
                                        n = Player(index).Target
                                    End If
                                Else
                                    If Spell(SpellNum).Type >= SPELL_TYPE_ADDHP And Spell(SpellNum).Type <= SPELL_TYPE_ADDSP Then
                                        If GetPlayerAccess(index) < 5 Then
                                            If GetPlayerHP(I) > 0 Then
                                                If (GetPlayerAccess(index) <= 1 And GetPlayerAccess(I) <= 1) Or (GetPlayerAccess(index) > 1 And GetPlayerAccess(I) > 1) Then
                                                    If GetPlayerAccess(n) <> 5 Then
                                                        If (Map(GetPlayerMap(I)).Tile(GetPlayerX(I), GetPlayerY(I)).Type = TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_ARENA) Or (Map(GetPlayerMap(I)).Tile(GetPlayerX(I), GetPlayerY(I)).Type <> TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type <> TILE_TYPE_ARENA) Then
                                                            Player(index).Target = I
                                                            Player(index).TargetType = TARGET_TYPE_PLAYER
                                                            n = Player(index).Target

                                                            Call SetPlayerMP(index, GetPlayerMP(index) - (Spell(SpellNum).MPCost / 10))
                                                            Call SendMP(index)
                                                        End If
                                                    End If
                                                End If
                                            End If
                                        Else
                                            Player(index).Target = I
                                            Player(index).TargetType = TARGET_TYPE_PLAYER
                                            n = Player(index).Target
                                        End If
                                    ElseIf Spell(SpellNum).Type >= SPELL_TYPE_SUBHP And Spell(SpellNum).Type <= SPELL_TYPE_SUBSP Then
                                        If GetPlayerAccess(index) < 5 Then
                                            If GetPlayerHP(I) > 0 Then
                                                If Map(GetPlayerMap(index)).Moral = MAP_MORAL_NONE Or Map(GetPlayerMap(index)).Moral = MAP_MORAL_NO_PENALTY Or GetPlayerPK(n) = YES Then
                                                    If (GetPlayerAccess(index) <= 1 And GetPlayerAccess(I) <= 1) Or (GetPlayerAccess(index) > 1 And GetPlayerAccess(I) > 1) Then
                                                        If GetPlayerLevel(index) >= 5 Then
                                                            If GetPlayerLevel(I) >= 5 Then
                                                                If GetPlayerAccess(I) <> 5 Then
                                                                    If LenB(GetPlayerGuild(index)) <> 0 Then
                                                                        If Trim$(GetPlayerGuild(index)) <> Trim$(GetPlayerGuild(I)) Then
                                                                            If (Map(GetPlayerMap(I)).Tile(GetPlayerX(I), GetPlayerY(I)).Type = TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_ARENA) Or (Map(GetPlayerMap(I)).Tile(GetPlayerX(I), GetPlayerY(I)).Type <> TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type <> TILE_TYPE_ARENA) Then
                                                                                Player(index).Target = I
                                                                                Player(index).TargetType = TARGET_TYPE_PLAYER
                                                                                n = Player(index).Target

                                                                                Call SetPlayerMP(index, GetPlayerMP(index) - (Spell(SpellNum).MPCost / 10))
                                                                                Call SendMP(index)
                                                                            End If
                                                                        End If
                                                                    Else
                                                                        If (Map(GetPlayerMap(I)).Tile(GetPlayerX(I), GetPlayerY(I)).Type = TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_ARENA) Or (Map(GetPlayerMap(I)).Tile(GetPlayerX(I), GetPlayerY(I)).Type <> TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type <> TILE_TYPE_ARENA) Then
                                                                            Player(index).Target = I
                                                                            Player(index).TargetType = TARGET_TYPE_PLAYER
                                                                            n = Player(index).Target

                                                                            Call SetPlayerMP(index, GetPlayerMP(index) - (Spell(SpellNum).MPCost / 10))
                                                                            Call SendMP(index)
                                                                        End If
                                                                    End If
                                                                End If
                                                            End If
                                                        End If
                                                    End If
                                                End If
                                            End If
                                        Else
                                            Player(index).Target = I
                                            Player(index).TargetType = TARGET_TYPE_PLAYER
                                            n = Player(index).Target

                                            Call SetPlayerMP(index, GetPlayerMP(index) - (Spell(SpellNum).MPCost / 10))
                                            Call SendMP(index)
                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If
                Next I

                For I = 1 To MAX_MAP_NPCS
                    If MapNPC(GetPlayerMap(index), I).num > 0 Then
                        If NPC(MapNPC(GetPlayerMap(index), I).num).Behavior <> NPC_BEHAVIOR_FRIENDLY And NPC(MapNPC(GetPlayerMap(index), I).num).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then
                            If MapNPC(GetPlayerMap(index), I).x = x And MapNPC(GetPlayerMap(index), I).y = y Then
                                Player(index).Target = I
                                Player(index).TargetType = TARGET_TYPE_NPC
                                n = Player(index).Target

                                Call SetPlayerMP(index, GetPlayerMP(index) - (Spell(SpellNum).MPCost / 10))
                                Call SendMP(index)
                            End If
                        End If
                    End If
                Next I

                Casted = False
                If n > 0 Then
                    If Player(index).TargetType = TARGET_TYPE_PLAYER Then
                        If IsPlaying(n) Then
                            If n = index Then
                                Select Case Spell(SpellNum).Type
                                    Case SPELL_TYPE_ADDHP
                                        Call SetPlayerHP(n, GetPlayerHP(n) + Spell(SpellNum).Data1)
                                        Call SendHP(n)

                                    Case SPELL_TYPE_ADDMP
                                        Call SetPlayerMP(n, GetPlayerMP(n) + Spell(SpellNum).Data1)
                                        Call SendMP(n)

                                    Case SPELL_TYPE_ADDSP
                                        Call SetPlayerSP(n, GetPlayerSP(n) + Spell(SpellNum).Data1)
                                        Call SendSP(n)
                                End Select
                                Casted = True

                            ElseIf n <> index Then
                                Player(index).TargetType = TARGET_TYPE_PLAYER
                                If Spell(SpellNum).Type >= SPELL_TYPE_SUBHP And Spell(SpellNum).Type <= SPELL_TYPE_SUBSP Then

                                    Select Case Spell(SpellNum).Type
                                        Case SPELL_TYPE_SUBHP

                                            Damage = (Int(GetPlayerMAGI(index) / 4) + Spell(SpellNum).Data1) - GetPlayerProtection(n)
                                            If Damage > 0 Then
                                                Call AttackPlayer(index, n, Damage)
                                            Else
                                                Call BattleMsg(index, "The spell was to weak to hurt " & GetPlayerName(n) & "!", BRIGHTRED, 0)
                                            End If

                                        Case SPELL_TYPE_SUBMP
                                            Call SetPlayerMP(n, GetPlayerMP(n) - Spell(SpellNum).Data1)
                                            Call SendMP(n)

                                        Case SPELL_TYPE_SUBSP
                                            Call SetPlayerSP(n, GetPlayerSP(n) - Spell(SpellNum).Data1)
                                            Call SendSP(n)
                                    End Select

                                    Casted = True

                                ElseIf Spell(SpellNum).Type >= SPELL_TYPE_ADDHP And Spell(SpellNum).Type <= SPELL_TYPE_ADDSP Then

                                    Select Case Spell(SpellNum).Type
                                        Case SPELL_TYPE_ADDHP
                                            Call SetPlayerHP(n, GetPlayerHP(n) + Spell(SpellNum).Data1)
                                            Call SendHP(n)
                                        Case SPELL_TYPE_ADDMP
                                            Call SetPlayerMP(n, GetPlayerMP(n) + Spell(SpellNum).Data1)
                                            Call SendMP(n)
                                        Case SPELL_TYPE_ADDSP
                                            Call SetPlayerSP(n, GetPlayerSP(n) + Spell(SpellNum).Data1)
                                            Call SendSP(n)
                                    End Select

                                    Casted = True

                                End If
                            End If
                        Else
                            Call BattleMsg(index, "Could not cast spell!", BRIGHTRED, 0)
                        End If
                    Else
                        Player(index).TargetType = TARGET_TYPE_NPC
                        If NPC(MapNPC(GetPlayerMap(index), n).num).Behavior <> NPC_BEHAVIOR_FRIENDLY And NPC(MapNPC(GetPlayerMap(index), n).num).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then
                            If Spell(SpellNum).Type >= SPELL_TYPE_SUBHP And Spell(SpellNum).Type <= SPELL_TYPE_SUBSP Then
                                Select Case Spell(SpellNum).Type

                                    Case SPELL_TYPE_SUBHP
                                        Damage = (Int(GetPlayerMAGI(index) / 4) + Spell(SpellNum).Data1) - Int(NPC(MapNPC(GetPlayerMap(index), n).num).DEF / 2)

                                        If Damage > 0 Then
                                            If Spell(SpellNum).Element <> 0 And NPC(MapNPC(GetPlayerMap(index), n).num).Element <> 0 Then
                                                If Element(Spell(SpellNum).Element).Strong = NPC(MapNPC(GetPlayerMap(index), n).num).Element Or Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Weak = Spell(SpellNum).Element Then
                                                    Call BattleMsg(index, "A deadly mix of elements harm the " & Trim$(NPC(MapNPC(GetPlayerMap(index), n).num).Name) & "!", BLUE, 0)
                                                    Damage = Int(Damage * 1.25)
                                                    If Element(Spell(SpellNum).Element).Strong = NPC(MapNPC(GetPlayerMap(index), n).num).Element And Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Weak = Spell(SpellNum).Element Then
                                                        Damage = Int(Damage * 1.2)
                                                    End If
                                                End If

                                                If Element(Spell(SpellNum).Element).Weak = NPC(MapNPC(GetPlayerMap(index), n).num).Element Or Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Strong = Spell(SpellNum).Element Then
                                                    Call BattleMsg(index, "The " & Trim$(NPC(MapNPC(GetPlayerMap(index), n).num).Name) & " absorbs much of the elemental damage!", RED, 0)
                                                    Damage = Int(Damage * 0.75)
                                                    If Element(Spell(SpellNum).Element).Weak = NPC(MapNPC(GetPlayerMap(index), n).num).Element And Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Strong = Spell(SpellNum).Element Then
                                                        Damage = Int(Damage * (2 / 3))
                                                    End If
                                                End If
                                            End If
                                            Call AttackNpc(index, n, Damage)
                                        Else
                                            Call BattleMsg(index, "The spell was to weak to hurt " & Trim$(NPC(MapNPC(GetPlayerMap(index), n).num).Name) & "!", BRIGHTRED, 0)
                                        End If

                                    Case SPELL_TYPE_SUBMP
                                        MapNPC(GetPlayerMap(index), n).MP = MapNPC(GetPlayerMap(index), n).MP - Spell(SpellNum).Data1

                                    Case SPELL_TYPE_SUBSP
                                        MapNPC(GetPlayerMap(index), n).SP = MapNPC(GetPlayerMap(index), n).SP - Spell(SpellNum).Data1
                                End Select

                                Casted = True
                            End If
                        Else
                            Call BattleMsg(index, "Could not cast spell!", BRIGHTRED, 0)
                        End If
                    End If
                End If
                If Casted = True Then
                    Call SendDataToMap(GetPlayerMap(index), "spellanim" & SEP_CHAR & SpellNum & SEP_CHAR & Spell(SpellNum).SpellAnim & SEP_CHAR & Spell(SpellNum).SpellTime & SEP_CHAR & Spell(SpellNum).SpellDone & SEP_CHAR & index & SEP_CHAR & Player(index).TargetType & SEP_CHAR & Player(index).Target & SEP_CHAR & Player(index).CastedSpell & SEP_CHAR & Spell(SpellNum).Big & END_CHAR)
                    Call SendDataToMap(GetPlayerMap(index), "sound" & SEP_CHAR & "magic" & SEP_CHAR & Spell(SpellNum).Sound & END_CHAR)
                End If
            Next x
        Next y

        Call SetPlayerMP(index, GetPlayerMP(index) - Spell(SpellNum).MPCost)
        Call SendMP(index)
    Else
        n = Player(index).Target
        If Player(index).TargetType = TARGET_TYPE_PLAYER Then
            If IsPlaying(n) Then

                Player(index).TargetType = TARGET_TYPE_PLAYER

                If Spell(SpellNum).Type >= SPELL_TYPE_SUBHP And Spell(SpellNum).Type <= SPELL_TYPE_SUBSP Then
                    If GetPlayerAccess(index) < 5 Then
                        If GetPlayerMap(index) <> GetPlayerMap(n) Then
                            Call PlayerMsg(index, "You must be on the same map as your target!", BRIGHTRED)
                            Exit Sub
                        End If

                        If index = n Then
                            Call PlayerMsg(index, "You cannot attack yourself!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerHP(n) <= 0 Then
                            Call PlayerMsg(index, "This player is already void of life!", BRIGHTRED)
                            Exit Sub
                        End If

                        If Map(GetPlayerMap(index)).Moral <> MAP_MORAL_NONE And Map(GetPlayerMap(index)).Moral <> MAP_MORAL_NO_PENALTY And GetPlayerPK(n) <> YES Then
                            Call PlayerMsg(index, "This is a safe zone!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerAccess(index) > 1 And GetPlayerAccess(n) <= 1 Then
                            Call PlayerMsg(index, "You cannot attack players!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerAccess(index) <= 1 And GetPlayerAccess(n) > 1 Then
                            Call PlayerMsg(index, "You cannot attack staff!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerLevel(index) < 5 Then
                            Call PlayerMsg(index, "You must be above level 5 to attack players!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerLevel(n) < 5 Then
                            Call PlayerMsg(index, "Your target must be above level 5!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerAccess(n) = 5 Then
                            Call PlayerMsg(index, "You cannot attack this person!", BRIGHTRED)
                            Exit Sub
                        End If

                        If Trim$(GetPlayerGuild(index)) <> vbNullString And GetPlayerGuild(n) <> vbNullString Then
                            If Trim$(GetPlayerGuild(index)) = Trim$(GetPlayerGuild(n)) Then
                                Call PlayerMsg(index, "You cannot attack a guild member!", BRIGHTRED)
                                Exit Sub
                            End If
                        End If

                        If Map(GetPlayerMap(n)).Tile(GetPlayerX(n), GetPlayerY(n)).Type = TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type <> TILE_TYPE_ARENA Then
                            Call PlayerMsg(index, "You must be in the Arena to attack this person!", BRIGHTRED)
                            Exit Sub
                        ElseIf Map(GetPlayerMap(n)).Tile(GetPlayerX(n), GetPlayerY(n)).Type <> TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_ARENA Then
                            Call PlayerMsg(index, "Your opponent must be in the Arena!", BRIGHTRED)
                            Exit Sub
                        End If
                    End If

                    Select Case Spell(SpellNum).Type
                        Case SPELL_TYPE_SUBHP

                            Damage = (Int(GetPlayerMAGI(index) / 4) + Spell(SpellNum).Data1) - GetPlayerProtection(n)
                            If Damage > 0 Then
                                Call AttackPlayer(index, n, Damage)
                            Else
                                Call BattleMsg(index, "The spell was to weak to hurt " & GetPlayerName(n) & "!", BRIGHTRED, 0)
                            End If

                        Case SPELL_TYPE_SUBMP
                            Call SetPlayerMP(n, GetPlayerMP(n) - Spell(SpellNum).Data1)
                            Call SendMP(n)

                        Case SPELL_TYPE_SUBSP
                            Call SetPlayerSP(n, GetPlayerSP(n) - Spell(SpellNum).Data1)
                            Call SendSP(n)
                    End Select

                    ' Take away the mana points
                    Call SetPlayerMP(index, GetPlayerMP(index) - Spell(SpellNum).MPCost)
                    Call SendMP(index)
                    Casted = True

                ElseIf Spell(SpellNum).Type >= SPELL_TYPE_ADDHP And Spell(SpellNum).Type <= SPELL_TYPE_ADDSP Then
                    If GetPlayerAccess(index) < 5 Then
                        If GetPlayerMap(index) <> GetPlayerMap(n) Then
                            Call PlayerMsg(index, "You must be on the same map as your target!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerHP(n) <= 0 Then
                            Call PlayerMsg(index, "This player is already void of life!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerAccess(index) > 1 And GetPlayerAccess(n) <= 1 Then
                            Call PlayerMsg(index, "You cannot heal players!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerAccess(index) <= 1 And GetPlayerAccess(n) > 1 Then
                            Call PlayerMsg(index, "You cannot heal staff!", BRIGHTRED)
                            Exit Sub
                        End If

                        If GetPlayerAccess(n) = 5 Then
                            Call PlayerMsg(index, "You cannot heal this person!", BRIGHTRED)
                            Exit Sub
                        End If

                        If Map(GetPlayerMap(n)).Tile(GetPlayerX(n), GetPlayerY(n)).Type = TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type <> TILE_TYPE_ARENA Then
                            Call PlayerMsg(index, "You must be in the Arena too!", BRIGHTRED)
                            Exit Sub
                        ElseIf Map(GetPlayerMap(n)).Tile(GetPlayerX(n), GetPlayerY(n)).Type <> TILE_TYPE_ARENA And Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_ARENA Then
                            Call PlayerMsg(index, "Your opponent must be in the Arena too!", BRIGHTRED)
                            Exit Sub
                        End If
                    End If

                    Select Case Spell(SpellNum).Type

                        Case SPELL_TYPE_ADDHP
                            Call SetPlayerHP(n, GetPlayerHP(n) + Spell(SpellNum).Data1)
                            Call SendHP(n)
                        Case SPELL_TYPE_ADDMP
                            Call SetPlayerMP(n, GetPlayerMP(n) + Spell(SpellNum).Data1)
                            Call SendMP(n)
                        Case SPELL_TYPE_ADDSP
                            Call SetPlayerSP(n, GetPlayerSP(n) + Spell(SpellNum).Data1)
                            Call SendSP(n)
                    End Select

                    ' Take away the mana points
                    Call SetPlayerMP(index, GetPlayerMP(index) - Spell(SpellNum).MPCost)
                    Call SendMP(index)
                    Casted = True
                End If
            Else
                Call PlayerMsg(index, "Cannot cast spell!", BRIGHTRED)
            End If
        Else
            n = Player(index).TargetNPC
            If CInt(Sqr((GetPlayerX(index) - MapNPC(GetPlayerMap(index), n).x) ^ 2 + ((GetPlayerY(index) - MapNPC(GetPlayerMap(index), n).y) ^ 2))) > Spell(SpellNum).Range Then
                Call BattleMsg(index, "You are too far away to hit the target.", BRIGHTRED, 0)
                Exit Sub
            End If

            Player(index).TargetType = TARGET_TYPE_NPC

            If NPC(MapNPC(GetPlayerMap(index), n).num).Behavior <> NPC_BEHAVIOR_FRIENDLY And NPC(MapNPC(GetPlayerMap(index), n).num).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then

                Select Case Spell(SpellNum).Type
                    Case SPELL_TYPE_SUBHP

                        Damage = (Int(GetPlayerMAGI(index) / 4) + Spell(SpellNum).Data1) - Int(NPC(MapNPC(GetPlayerMap(index), n).num).DEF / 2)
                        If Damage > 0 Then
                            If Spell(SpellNum).Element <> 0 And NPC(MapNPC(GetPlayerMap(index), n).num).Element <> 0 Then
                                If Element(Spell(SpellNum).Element).Strong = NPC(MapNPC(GetPlayerMap(index), n).num).Element Or Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Weak = Spell(SpellNum).Element Then
                                    Call BattleMsg(index, "A deadly mix of elements harm the " & Trim$(NPC(MapNPC(GetPlayerMap(index), n).num).Name) & "!", BLUE, 0)
                                    Damage = Int(Damage * 1.25)
                                    If Element(Spell(SpellNum).Element).Strong = NPC(MapNPC(GetPlayerMap(index), n).num).Element And Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Weak = Spell(SpellNum).Element Then
                                        Damage = Int(Damage * 1.2)
                                    End If
                                End If

                                If Element(Spell(SpellNum).Element).Weak = NPC(MapNPC(GetPlayerMap(index), n).num).Element Or Element(NPC(MapNPC(GetPlayerMap(index), n).num).Element).Strong = Spell(SpellNum).Element Then
                                    Call BattleMsg(index, "The " & Tr
```
Link to comment
Share on other sites

@[SB:

> The Soul Numb link=topic=53130.msg562742#msg562742 date=1256163893]
> I would change the "You can't attack staff" check to 1, that way moderators don't get an advantage.
>
> But this is really cool, thanks for releasing it :).

o.0 it's set to  "access > 0" , which would include 1.

Oh, I'd also like to point out the Void of life may have a "glitch" for some of you. I used it as an event, to use items to allow players to reach Hp of 0, which wouldn't make them die, thus while having 0 you cannot be attacked by magic. It was a zombie event, but that can be changed.
Link to comment
Share on other sites

@[SB:

> The Soul Numb link=topic=53130.msg562742#msg562742 date=1256163893]
> I would change the "You can't attack staff" check to 1, that way moderators don't get an advantage.
>
> But this is really cool, thanks for releasing it :).

o.0 it's set to  "access > 0" , which would include 1.

Oh, I'd also like to point out the Void of life may have a "glitch" for some of you. I used it as an event, to use items to allow players to reach Hp of 0, which wouldn't make them die, thus while having 0 you cannot be attacked by magic. It was a zombie event, but that can be changed.
Link to comment
Share on other sites

oh@[SB:

> The Soul Numb link=topic=53130.msg562760#msg562760 date=1256165053]
> Moderators will get an unfair advantage against other players. The point of the mod status is too have a rank that can kick players but allows them to play the game normally.

ooohez, so you're saying they "should" be able to attack other players? If not, I'm confused, lol.

Right now it's set so that Mods can attack other Staff, and not players, as well as players cannot attack mods.
Link to comment
Share on other sites

oh@[SB:

> The Soul Numb link=topic=53130.msg562760#msg562760 date=1256165053]
> Moderators will get an unfair advantage against other players. The point of the mod status is too have a rank that can kick players but allows them to play the game normally.

ooohez, so you're saying they "should" be able to attack other players? If not, I'm confused, lol.

Right now it's set so that Mods can attack other Staff, and not players, as well as players cannot attack mods.
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...