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

Fixing combat


teh jimpie
 Share

Recommended Posts

hi

after i used vidhoots advanced attack system my combat is a bit bugged.
when i die, i get a error; i just die like normal, but my server gives a error and that really frustrating. example: my server might crash when there are 10 ppl going die at same time, like a massa kill or something. the cb isnt 100% too so i want it back.

i replaced onarrowhit, onattack, and onplayerhit with a new, clear and fresh one.
still got the error when i die:

type: subscript out of range
line: 10
column: 0
code:

please help me to fix this.

the script;

```
' Executes when a player presses the CONTROL key.
Sub OnAttack(Index, Damage)
Dim Target
                  Dim random
                  Dim npcnum

  npcnum = GetPlayerTargetNPC(Index)
random = Rand(1 , 20)

  If GetPlayerDir(index) = 0 Then
      Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetNpcY(GetPlayerMap(index), npcnum))
  End If
  If GetPlayerDir(index) = 1 Then
      Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetNpcY(GetPlayerMap(index), npcnum))
  End If
  If GetPlayerDir(index) = 2 Then
      Call SpellAnim(1, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
  End If
  If GetPlayerDir(index) = 3 Then
      Call SpellAnim(1, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
  End If
      Select Case random

              Case 1

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
Call DamagePlayer(Index, Target, Damage * 2)
                                                        Call BattleMsg(index , " You Striked your enemy with a powerful critical hit " , 12 , 0)
Else
Target = GetPlayerTargetNPC(Index)
Call DamageNPC(Index, Target, Damage * 2)
                                                        Call BattleMsg(index , " You Striked your enemy with a powerful critical hit " , 12 , 0 )
End If
End If

                  Exit Sub

              Case 2

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                                                        Call BattleMsg(index , " You have missed your hit! " , 12 , 0 )
Else
Target = GetPlayerTargetNPC(Index)
                                                        Call BattleMsg(index , " You have missed your hit " , 12 , 0)
End If
End If

                  Exit Sub

              Case 3

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
Call DamagePlayer(Index, Target, Damage / 2)
                                                        Call BattleMsg(index , "You have Hit your enemy with a bad strike", 12 , 0 )
Else
Target = GetPlayerTargetNPC(Index)
Call DamageNPC(Index, Target, Damage / 2)
                                                        Call BattleMsg(index , "You have Hit your enemy with a bad strike", 12 , 0 )
End If
End If

                  Exit Sub

              Case Else

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
Call DamageNPC(Index, Target, Damage)
End If
End If

                  Exit Sub

End Select

End Sub

Sub OnArrowHit(Index, Damage)
Dim Target
                  Dim random
                  Dim npcnum

  npcnum = GetPlayerTargetNPC(Index)
random = Rand(1 , 20)

  If GetPlayerDir(index) = 0 Then
      Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetNpcY(GetPlayerMap(index), npcnum))
  End If
  If GetPlayerDir(index) = 1 Then
      Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetNpcY(GetPlayerMap(index), npcnum))
  End If
  If GetPlayerDir(index) = 2 Then
      Call SpellAnim(1, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
  End If
  If GetPlayerDir(index) = 3 Then
      Call SpellAnim(1, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
  End If
      Select Case random

              Case 1

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
Call DamagePlayer(Index, Target, Damage * 2)
                                                        Call BattleMsg(index , " You Striked your enemy with a powerful critical hit " , 12 , 0)
Else
Target = GetPlayerTargetNPC(Index)
Call DamageNPC(Index, Target, Damage * 2)
                                                        Call BattleMsg(index , " You Striked your enemy with a powerful critical hit " , 12 , 0 )
End If
End If

                  Exit Sub

              Case 2

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                                                        Call BattleMsg(index , " You have missed your hit! " , 12 , 0 )
Else
Target = GetPlayerTargetNPC(Index)
                                                        Call BattleMsg(index , " You have missed your hit " , 12 , 0)
End If
End If

                  Exit Sub

    Case 3

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
Call DamagePlayer(Index, Target, Damage / 2)
                                                        Call BattleMsg(index , "You have Hit your enemy with a bad strike", 12 , 0 )
Else
Target = GetPlayerTargetNPC(Index)
Call DamageNPC(Index, Target, Damage / 2)
                                                        Call BattleMsg(index , "You have Hit your enemy with a bad strike", 12 , 0 )
End If
End If

                  Exit Sub
  Case Else

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
Call DamageNPC(Index, Target, Damage)
End If
End If

                  Exit Sub

End Select
End Sub

Sub PlayerHit(Index, NPCNum, Damage)
Dim Random

Random = Rand(1 , 20 )

Select Case Random

          Case 1
If Damage > 0 then
Call NPCAttack(NPCNum, Index, Damage * 2)
                                    Call BattleMsg(index , " You have been hit with a critical strike! " , 12 , 0 )
End If
        Exit Sub

          Case 2
    If GetPlayerShieldSlot(index) > 0 Then
            Call BattleMsg(index , " You blocked your enemy's hit " , 12 , 0 )
    End If
If Damage > 0 then
Call NPCAttack(NPCNum, Index, Damage)
End If
        Exit Sub

          Case 3
Call BattleMsg(index , " You parried your enemy's hit " , 12 , 0 )
        Exit Sub

          Case 4
Call BattleMsg(index , " You dodged your enemy's hit " , 12 , 0 )
        Exit Sub
  Case Else
If Damage > 0 then
Call NPCAttack(NPCNum, Index, Damage)
End If
        Exit Sub

End Select

End Sub
```
Link to comment
Share on other sites

1\. i think i forgot to place this (first code down): In what .ess do i put it? because while deleting i didnt found this

2\. grats with ur mod lol  :P

```
' Executes when a player presses the CONTROL key.
Sub OnAttack(Index, Damage)
Dim Target
                  Dim random
                  Dim npcnum

  npcnum = GetPlayerTargetNPC(Index)
random = Rand(1 , 20)

  If GetPlayerDir(index) = 0 Then
      Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetNpcY(GetPlayerMap(index), npcnum))
  End If
  If GetPlayerDir(index) = 1 Then
      Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetNpcY(GetPlayerMap(index), npcnum))
  End If
  If GetPlayerDir(index) = 2 Then
      Call SpellAnim(1, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
  End If
  If GetPlayerDir(index) = 3 Then
      Call SpellAnim(1, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
  End If
      Select Case random

              Case 1

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
Call DamagePlayer(Index, Target, Damage * 2)
                                                        Call BattleMsg(index , " You Striked your enemy with a powerful critical hit " , 12 , 0)
Else
Target = GetPlayerTargetNPC(Index)
Call DamageNPC(Index, Target, Damage * 2)
                                                        Call BattleMsg(index , " You Striked your enemy with a powerful critical hit " , 12 , 0 )
End If
End If

                  Exit Sub

              Case 2

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                                                        Call BattleMsg(index , " You have missed your hit! " , 12 , 0 )
Else
Target = GetPlayerTargetNPC(Index)
                                                        Call BattleMsg(index , " You have missed your hit " , 12 , 0)
End If
End If

                  Exit Sub

              Case 3

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
Call DamagePlayer(Index, Target, Damage / 2)
                                                        Call BattleMsg(index , "You have Hit your enemy with a bad strike", 12 , 0 )
Else
Target = GetPlayerTargetNPC(Index)
Call DamageNPC(Index, Target, Damage / 2)
                                                        Call BattleMsg(index , "You have Hit your enemy with a bad strike", 12 , 0 )
End If
End If

                  Exit Sub

              Case Else

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
Call DamageNPC(Index, Target, Damage)
End If
End If

                  Exit Sub

End Select

End Sub
```my sub ondeath
```
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Module: OnDeath.ess '
' Author: Stephan J.R. van Schaik '
' Date: August 30th, 2009. '
' Version: 1.0.0 '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: OnDeath '
' Brief: executes when a player dies outside of an arena. '
' Parameters: '
' Index: the index number of the player who died. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub OnDeath(Index)
If GetMapBootMap(Index) > 0 Then
Call PlayerWarp(Index, GetMapBootMap(Index), GetMapBootX(Index), GetMapBootY(Index))
Else
Map = CInt(GetVar("Classes\Class" & GetPlayerClass(Index) & ".ini", "CLASS", "Map"))
X = CInt(GetVar("Classes\Class" & GetPlayerClass(Index) & ".ini", "CLASS", "x"))
Y = CInt(GetVar("Classes\Class" & GetPlayerClass(Index) & ".ini", "CLASS", "y"))

Call PlayerWarp(Index, Map, X, Y)
End If

Call SetPlayerHP(Target, GetPlayerMaxHP(Target))
Call SetPlayerMP(Target, GetPlayerMaxMP(Target))
Call SetPlayerSP(Target, GetPlayerMaxSP(Target))
Call SendPlayerData(Target)
End Sub

```
Link to comment
Share on other sites

```
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Module: OnDeath.ess '
' Author: Stephan J.R. van Schaik '
' Date: August 30th, 2009. '
' Version: 1.0.0 '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: OnDeath '
' Brief: executes when a player dies outside of an arena. '
' Parameters: '
' Index: the index number of the player who died. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub OnDeath(Index)
If GetMapBootMap(Index) > 0 Then
Call PlayerWarp(Index, GetMapBootMap(Index), GetMapBootX(Index), GetMapBootY(Index))
Else
Map = CInt(GetVar("Classes\Class" & GetPlayerClass(Index) & ".ini", "CLASS", "Map"))
X = CInt(GetVar("Classes\Class" & GetPlayerClass(Index) & ".ini", "CLASS", "x"))
Y = CInt(GetVar("Classes\Class" & GetPlayerClass(Index) & ".ini", "CLASS", "y"))

Call PlayerWarp(Index, Map, X, Y)
End If

Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
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...