mrmiguu Posted November 1, 2008 Author Share Posted November 1, 2008 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 More sharing options...
DarkMazer Posted November 2, 2008 Share Posted November 2, 2008 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 IfEnd 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 More sharing options...
mrmiguu Posted November 27, 2008 Author Share Posted November 27, 2008 Doesn't work, damn! Link to comment Share on other sites More sharing options...
zade_o Posted November 27, 2008 Share Posted November 27, 2008 cant you just put a timer at the end of the do while loop? and remove the timer at the beginning? …. Link to comment Share on other sites More sharing options...
DarkMazer Posted November 28, 2008 Share Posted November 28, 2008 I forgot some commas. Hopefully it works now. Link to comment Share on other sites More sharing options...
mrmiguu Posted November 28, 2008 Author Share Posted November 28, 2008 It works, it just keeps looping, but i think all it needs is a readjustment of the removetimer thingy and it will work, because the way it's setup atm is it keeps looping the timer and it wont stop until the monster dies. Link to comment Share on other sites More sharing options...
DarkMazer Posted November 28, 2008 Share Posted November 28, 2008 It looks like the problem is the game was trying to use NPCNum as a variable even though there was nothing in it. I edited the script one last time (hopefully) to take that into account, and it should be able to remove the timer properly now. Link to comment Share on other sites More sharing options...
mrmiguu Posted November 28, 2008 Author Share Posted November 28, 2008 Now it stops, but I think it does it around 10 attacks, it's doing what I want to do, but is there a way I can hold it back to a specified amount of times such as 2? or maybe 3? Link to comment Share on other sites More sharing options...
dg1423 Posted November 28, 2008 Share Posted November 28, 2008 use this code:```if GetPlayerTarget(index) > 0 And GetPlayerTarget(index) <> index thenCall SetTimer("MakeAttackP " & index & "," & damage & "," & Target & "," & Attacks, 200)elseCall 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 ifEnd SubSub 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 ifEnd Sub```should work o_O Link to comment Share on other sites More sharing options...
mrmiguu Posted December 10, 2008 Author Share Posted December 10, 2008 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 SubThis 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 More sharing options...
DarkMazer Posted December 10, 2008 Share Posted December 10, 2008 In this part:```if GetPlayerTarget(index) > 0 And GetPlayerTarget(index) <> index thenCall SetTimer("MakeAttackP " & index & "," & damage & "," & Target & "," & Attacks, 200)elseCall 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 More sharing options...
mrmiguu Posted December 10, 2008 Author Share Posted December 10, 2008 ::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 More sharing options...
DarkMazer Posted December 11, 2008 Share Posted December 11, 2008 @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 thenCall SetTimer("MakeAttackP " & index & "," & damage & "," & Target & ", 2", 100)elseCall 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now