ryono Posted March 27, 2009 Author Share Posted March 27, 2009 hey people of eclipse. I need some help. I made a script that is basically a regular attack script. the script will get whoevever you attacking's index and then attack them. basically the same as the standard ctrl attack. but without the animation. so yeah here it is, see if you can find anything wrong:```Sub RegularAttack(Index, High, Low, HitAnim, MissAnim, CritAnim, RevAnim, HitSound, MissSound, CritSound, RevSound) Dim TR Dim I Dim TI Dim Dmg Dim M Dim PX Dim PY Dim TX Dim TY Dim CH Dim HT I = Index TR = TargetReverse(I) TI = TargetIndex(I) Dmg = Rand(High, Low) M = GetPlayerMap(I) PX = GetPlayerX(I) PY = GetPlayerY(I) TX = GetPlayerX(TI) TY = GetPLayerY(TI) CH = IsCriticalHit(I) HT = HitType(I) If HT = 2 Then Call SpellAnim(CritAnim, M, TX, TY) Call DamagePlayer(TI, Dmg + 12) Call PlaySoundToMap(I, CritSound) ElseIf HT = 1 Then If TR = 1 Then Call DamagePlayer(I, Dmg) Call SpellAnim(RevAnim, M, PX, PY) Call PlaySoundToMap(I, RevSound) Else Call SpellAnim(HitAnim, M, TX, TY) Call DamagePlayer(TI, Dmg) Call PlaySoundToMap(I, HitSound) End If Else If Dir = 0 Then Call SpellAnim(MissAnim, M, PX, PY - 1) ElseIf Dir = 1 Then Call SpellAnim(CritAnim, M, PX, PY + 1) ElseIf Dir = 2 Then Call SpellAnim(CritAnim, M, PX - 1, PY) Else Call SpellAnim(CritAnim, M, PX + 1, PY) End If Call PlaySoundToMap(I, MissSound) End IfEnd SubFunction TargetIndex(Index) Dim Count Dim I Dim Map Dim Players Dim Dir Dim PX Dim PY Dim T Dim TX Dim TY I = Index Map = GetPlayerMap(I) Players = GetPlayersOnMap(Map) Dir = GetPlayerDir(I) PX = GetPlayerX(I) PY = GetPlayerY(I) TX = GetPlayerX(Count) TY = GetPlayerY(Count) TargetIndex = 0 For Count = 0 to Players Select Case Dir Case 0 If PX = TX And PY = TY + 1 Then TargetIndex = Count Exit Function End If Case 1 If PX = TX And PY = TY - 1 Then TargetIndex = Count Exit Function End If Case 2 If PX = TX + 1 And PY = TY Then TargetIndex = Count Exit Function End If Case Else If PX = TX - 1 And PY = TY Then TargetIndex = Count Exit Function End If End Select NextEnd FunctionFunction IsCriticalHit(Index) Dim PD Dim TD Dim I Dim TI I = Index TI = TargetIndex(I) PD = GetPlayerDir(I) TD = GetPlayerDir(TI) IsCriticalHit = 0 If PD = 0 And TD = 0 Or _ PD = 1 And TD = 1 Or _ PD = 2 And TD = 2 Or _ PD = 3 And TD = 3 Then IsCriticalHit = 1 End IfEnd FunctionFunction HitType(Index) Dim TI Dim CH TI = TargetIndex(Index) CH = IsCriticalHit(Index) If TI > 0 Then If CH = 1 Then HitType = 2 Else HitType = 1 End If Else HitType = 0 End IfEnd FunctionFunction TargetReverse(Index) Dim I Dim TI Dim TN Dim TR I = Index TI = TargetIndex(I) TN = GetPlayerName(TI) TR = GetVar("Reverse.ini", "REVERSE", TN) If TR = "1" Then TargetReverse = 1 End IfEnd Function```thank you for whoever tries to help me, or to whoever even looks at this post. Link to comment Share on other sites More sharing options...
Alpha Posted March 27, 2009 Share Posted March 27, 2009 TR = **"**1**"**I'm horrible at scripting, but that actually might be the bug you're looking at.Should the TR have no quotations?-Alpha Link to comment Share on other sites More sharing options...
ryono Posted March 27, 2009 Author Share Posted March 27, 2009 no it needs quotations because of getvar. it gets a string variable. I really appreciate the attempt though. Link to comment Share on other sites More sharing options...
Alpha Posted March 27, 2009 Share Posted March 27, 2009 Ah I don't know anything. But: TR = GetVar("Reverse.ini", "REVERSE", **TN**)Is the TN in bold supposed to be TR?-Alpha Link to comment Share on other sites More sharing options...
Admiral Refuge Posted March 27, 2009 Share Posted March 27, 2009 I just checked for Syntax errors, and this segment of code came up:``` If PD = 0 And TD = 0 Or _ PD = 1 And TD = 1 Or _ PD = 2 And TD = 2 Or _ PD = 3 And TD = 3 Then   IsCriticalHit = 1``` Link to comment Share on other sites More sharing options...
ryono Posted March 27, 2009 Author Share Posted March 27, 2009 no. TN stands for Target Name. once again nice try though. I aprreciate it. I'll take any ideas you have. Link to comment Share on other sites More sharing options...
ryono Posted March 27, 2009 Author Share Posted March 27, 2009 The entire thing? anyway, I think I know what it might be. its looking for the player dir, but if the index = 0 then it will get a syntax error, becasue there is no index. so. i'll try that and see if it works. Thank you very much for your input, I appreciate it.Edit: It still does not work. Link to comment Share on other sites More sharing options...
Admiral Refuge Posted March 27, 2009 Share Posted March 27, 2009 @ryono:> The entire thing? anyway, I think I know what it might be. its looking for the player dir, but if the index = 0 then it will get a syntax error, becasue there is no index. so. i'll try that and see if it works. Thank you very much for your input, I appreciate it.Yea, look:![](http://i41.tinypic.com/21l7sb5.jpg)Anyway, I'm not the best at sadscript, but what is that "Or _" for? Link to comment Share on other sites More sharing options...
ryono Posted March 27, 2009 Author Share Posted March 27, 2009 well "Or" is to add another condition to the if then statement. the " _" is a sentence concatenator for code. you can continue code on a different line. Link to comment Share on other sites More sharing options...
Admiral Refuge Posted March 27, 2009 Share Posted March 27, 2009 Oh, I see (guess that confused my editor)Anyway, let me know if that issue fixed the subscript problem.If all else fails, you can always set it in the data.ini to turn off the errors, and debug the script Link to comment Share on other sites More sharing options...
Alpha Posted March 27, 2009 Share Posted March 27, 2009 Haha, no one is good at Sadscript anymore. We need some of the good people in here!But using the Sadscript editor was a good idea, I have never tried that for checking scripts!-Alpha Link to comment Share on other sites More sharing options...
ryono Posted March 27, 2009 Author Share Posted March 27, 2009 nah it didn't help it. one again I really appreciate all of your input. both of you. Link to comment Share on other sites More sharing options...
balliztik1 Posted March 30, 2009 Share Posted March 30, 2009 Found the problem.```Players = GetPlayersOnMap(Map)...For Count = 0 to Players```_Players_ is set equal to the number of players on a map. This is NOT an array of their respective indices. As such, when you're trying to retrieve a player's index from their position on the map, you are not succeeding. For example, someone in map slot 2 might be right in front of player _Index_, but their true index number could be something far different, like 11\. Only by pure coincidence will you actually receive their true index value.The only way to counter this is to run the check for ALL indices. However, one more error prevents even that from working.``` TX = GetPlayerX(Count) TY = GetPlayerY(Count)```These two declarations are _outside_ the for-statement. As such, when Count changes, the values do not. Simply move them inside to fix this. 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