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

Displaying a spell animation?


Squiddle
 Share

Recommended Posts

Hi everyone, it's my, Squiddle :happy4:. I'm having a problem. I am using this script by Mr Miguu which draws a spell animation over the enemy you're attacking. It looks like this:

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

  If GetPlayerDir(index) = 0 Then
Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index) - 1)
      End If
      If GetPlayerDir(index) = 1 Then
    Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index) + 1)
      End If
      If GetPlayerDir(index) = 2 Then
Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index) - 1, GetPlayerY(index))
      End If
      If GetPlayerDir(index) = 3 Then
Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index) + 1, GetPlayerY(index))
    End If

```
It tells you to replace the ENTIRE onAttack sub, but I didn't want to replace my onAttack sub, so I tried to peice it together like this:

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

  If GetPlayerDir(index) = 0 Then
Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index) - 1)
      End If
      If GetPlayerDir(index) = 1 Then
    Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index) + 1)
      End If
      If GetPlayerDir(index) = 2 Then
Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index) - 1, GetPlayerY(index))
      End If
      If GetPlayerDir(index) = 3 Then
Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index) + 1, GetPlayerY(index))
    End If

  Range = Rand(Int(Damage) - 2, Int(Damage) + 2)

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

End Sub
```
As you can see, I have no idea where also to put it. Help please ^.^.
Link to comment
Share on other sites

Add

Function GetPlayerDirX(index)
If GetPlayerDir(index) = 0 Then
GetPlayerDirX = GetPlayerX(index)
ElseIf GetPlayerDir(index) = 1 Then
GetPlayerDirX = GetPlayerX(index)
ElseIf GetPlayerDir(index) = 2 Then
GetPlayerDirX = GetPlayerX(index) - 1
ElseIf GetPlayerDir(index) = 3 Then
GetPlayerDirX = GetPlayerX(index) + 1
End If
End Function

'Returns the Y of the tile in front of the player
Function GetPlayerDirY(index)
If GetPlayerDir(index) = 0 Then
GetPlayerDirY = GetPlayerY(index) - 1
ElseIf GetPlayerDir(index) = 1 Then
GetPlayerDirY = GetPlayerY(index) + 1
ElseIf GetPlayerDir(index) = 2 Then
GetPlayerDirY = GetPlayerY(index)
ElseIf GetPlayerDir(index) = 3 Then
GetPlayerDirY = GetPlayerY(index)
End If
End Function

To your main.txt Then in the on attack, use the simple call spellanim(index  and where X and Y loc are, use variables with getplayerdirx and getplayerdiry in their locations, will make the spell anim play right in front of you
Link to comment
Share on other sites

Okay, I still don't think I have it right. Here is my code:

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

  Call SpellAnim(1, GetPlayerMap(index), GetPlayerDirX(index), GetPlayerDirY(index))

  Range = Rand(Int(Damage) - 2, Int(Damage) + 2)

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

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

This is from my main that I'm currently working on, however this should work. Hopefully it helps.

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

  Range = Rand(Int(Damage) - 3, Int(Damage) + 3)

  If Int(Range) > 0 Then
      If Int(GetPlayerTarget(Index)) > 0 Then
        Target = GetPlayerTarget(Index)
        Call DamagePlayer(Index, Target, Range)
Call SpellAnim(1, GetPlayerMap(index), GetPlayerDirX(index), GetPlayerDirY(index))

      Else
        Target = GetPlayerTargetNPC(Index)
        Call DamageNPC(Index, Target, Range)
Call SpellAnim(1, GetPlayerMap(index), GetPlayerDirX(index), GetPlayerDirY(index))

      End If
  Else
      If Int(GetPlayerTarget(Index)) > 0 Then
        Target = GetPlayerTarget(Index)
        Call DamagePlayer(Index, Target, 0)
Call SpellAnim(1, GetPlayerMap(index), GetPlayerDirX(index), GetPlayerDirY(index))

      Else
        Target = GetPlayerTargetNPC(Index)
        Call DamageNPC(Index, Target, 0)
Call SpellAnim(1, GetPlayerMap(index), GetPlayerDirX(index), GetPlayerDirY(index))

      End If

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