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

Double attack (not double dmg) Help-p10x!


mrmiguu
 Share

Recommended Posts

I got the script to double attack, but I want each attack separated by about 100 milliseconds, I'm not sure how to configure it with timers properly (I have tried already) But if someone could give me some assistance, well that would be great!

> Case 2
> Dim Target
> Dim Range
> Dim npcnum
> Dim X
>
> Range = GetPlayerDamage(Index) * 1.5
> npcnum = GetPlayerTargetNPC(Index)
>
> Call SetPlayerMP(Index, GetPlayerMP(Index) - 10)
> Do While X < 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
> End If
> If GetPlayerDir(index) = 2 Then
> Call SpellAnim(4, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
> End If
> If GetPlayerDir(index) = 3 Then
> Call SpellAnim(4, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
> End If
> X = X + 1
> Loop
Link to comment
Share on other sites

I think I know how you could make the timer work.

Put this in a separate sub, something like Sub Attacks:
```
Sub Attacks(Index, Target, Range)
        Dim npcnum

        npcnum = GetPlayerTargetNPC(Index)

        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
        End If
        If GetTimer("Attacks " & Index & ", " & Target & ", " & Range) >= 0 Then
            Call RemoveTimer("Attacks " & Index & ", " & Target & ", " & Range)
        End If
        If GetPlayerDir(index) = 2 Then
            Call SpellAnim(4, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
        End If
        If GetPlayerDir(index) = 3 Then
            Call SpellAnim(4, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
        End If
End Sub
```
Under the case you're running this in, put this:
```
Case 2
        Dim Target
        Dim Range

        Range = GetPlayerDamage(Index) * 1.5

        Call SetPlayerMP(Index, GetPlayerMP(Index) - 10)
        Call Attacks(Index, Target, Range)
        Call SetTimer("Attacks " & Index & ", " & Target & ", " & Range, 100)

```
The way this works is, when you run the case you make your first attack and set a timer for the second one, and when the timer expires, the second attack is made and the timer is removed.  The fun thing is that the timer is removed only if it is running, so you shouldn't have any bugs with that. 

Of course, you may want to randomize damage inside Sub Attacks so both attacks can deal different amounts of damage, but I think you can figure that out.
Link to comment
Share on other sites

  • 4 weeks later...
use this code:

```
if GetPlayerTarget(index) > 0 And GetPlayerTarget(index) <> index then
Call SetTimer("MakeAttackP " & index & "," & damage & "," & Target & "," & Attacks, 200)
else
Call SetTimer("MakeAttackN " & index & "," & damage & "," & Target & "," & Attacks, 200)
end if
```
and use these subs:

```
Sub MakeAttackP(Index, Damage, Target, Attacks)
Call RemoveTimer("MakeAttackP " & index & "," & Damage & "," & Target & "," & Attacks) 
Attacks = Attacks - 1

Call DamagePlayer(Index, Target, Damage)
Call SpellAnim(4, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
if Attacks > 0 then
Call SetTimer("MakeAttackP " & index & "," & Damage & "," & Target & "," & Attacks, 200)
end if
End Sub

Sub MakeAttackN(Index, Damage, Target, Attacks)
Call RemoveTimer("MakeAttackN " & index & "," & Damage & "," & Target & "," & Attacks) 
Attacks = Attacks - 1

Call DamageNPC(Index, Target, Damage)
Call SpellAnim(4, GetPlayerMap(index), GetNPCX(GetPlayerMap(index), Target), GetNPCY(GetPlayerMap(index), Target))
if Attacks > 0 then
Call SetTimer("MakeAttackN " & index & "," & Damage & "," & Target & "," & Attacks, 200)
end if
End Sub

```
should work o_O
Link to comment
Share on other sites

  • 2 weeks later...
So does that need Dims I'm assuming? Im not familiar with where the damage doesnt have a specified variable attached to it. Please clarify this script for me if it's incomplete, I get confused with scripts that aren't completed or are different as far as the way they are written due to my lack of knowledge as far as timers req. dims or not… I don't even think what I just wrote down made any sense. O_O;

... ok, heres what I used to test out just the timer situation

> Sub MakeAttackP(Index, Damage, Target, Attacks)
>   Call RemoveTimer("MakeAttackP " & index & "," & Damage & "," & Target & "," & Attacks)
>   Attacks = Attacks - 1
>  
>   'Call DamagePlayer(Index, Target, Damage)
>   'Call SpellAnim(4, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
> Call PlayerMsg(Index, "The basic double stab works!", 14)
>   if Attacks > 0 then
>       Call SetTimer("MakeAttackP " & index & "," & Damage & "," & Target & "," & Attacks, 200)
>   end if
> End Sub
>
> Sub MakeAttackN(Index, Damage, Target, Attacks)
>   Call RemoveTimer("MakeAttackN " & index & "," & Damage & "," & Target & "," & Attacks)
>   Attacks = Attacks - 1
>  
>   'Call DamageNPC(Index, Target, Damage)
>   'Call SpellAnim(4, GetPlayerMap(index), GetNPCX(GetPlayerMap(index), Target), GetNPCY(GetPlayerMap(index), Target))
> Call PlayerMsg(Index, "The basic double stab works!", 14)
>   if Attacks > 0 then
>       Call SetTimer("MakeAttackN " & index & "," & Damage & "," & Target & "," & Attacks, 200)
>   end if
> End Sub

This way it only calls the msg, but i get RTE9 so odds are the timers are busted… any idea David?
Link to comment
Share on other sites

In this part:
```
if GetPlayerTarget(index) > 0 And GetPlayerTarget(index) <> index then
Call SetTimer("MakeAttackP " & index & "," & damage & "," & Target & "," & Attacks, 200)
else
Call SetTimer("MakeAttackN " & index & "," & damage & "," & Target & "," & Attacks, 200)
end if

```You have to fill in Attacks with how many attacks you want to make (2, probably).  You also have to make sure Index, Target, and Damage are defined properly.
Link to comment
Share on other sites

::EDIT::
I figured it out and it works perfectly! Thank you so much for your help David, and you too Dark Mazer.

@DarkMazer:

> In this part:
> ```
> if GetPlayerTarget(index) > 0 And GetPlayerTarget(index) <> index then
> Call SetTimer("MakeAttackP " & index & "," & damage & "," & Target & "," & Attacks, 200)
> else
> Call SetTimer("MakeAttackN " & index & "," & damage & "," & Target & "," & Attacks, 200)
> end if
>
> ```You have to fill in Attacks with how many attacks you want to make (2, probably).  You also have to make sure Index, Target, and Damage are defined properly.

defined in the spell case? and put the attack time in the settimer thing? (edit the & Attacks & to & 2 &?)
Link to comment
Share on other sites

@MrMiguuâ„¢:

> defined in the spell case? and put the attack time in the settimer thing? (edit the & Attacks & to & 2 &?)

Yep, they need to be defined in the spell case, if they're not already.  The script would probably end up looking like this:
```
if GetPlayerTarget(index) > 0 And GetPlayerTarget(index) <> index then
Call SetTimer("MakeAttackP " & index & "," & damage & "," & Target & ", 2", 100)
else
Call SetTimer("MakeAttackN " & index & "," & damage & "," & Target & ", 2", 100)
end if

```I made the time 100 milliseconds because that's what you said you wanted earlier.  For the attack thing, I just made Attacks 2 and then took out the &, but that should make it work.
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...