Squiddle Posted February 12, 2009 Author Share Posted February 12, 2009 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 IfEnd Sub```As you can see, I have no idea where also to put it. Help please ^.^. Link to comment Share on other sites More sharing options...
Doomsalad Posted February 12, 2009 Share Posted February 12, 2009 sorry…what exactly are you trying to do? Link to comment Share on other sites More sharing options...
Squiddle Posted February 12, 2009 Author Share Posted February 12, 2009 Oh sorry, forgot to explain my prbolem ^.^". I'm having the problem that the animation is not showing up when I attack a monster. Link to comment Share on other sites More sharing options...
DrNova Posted February 12, 2009 Share Posted February 12, 2009 AddFunction GetPlayerDirX(index)If GetPlayerDir(index) = 0 ThenGetPlayerDirX = GetPlayerX(index)ElseIf GetPlayerDir(index) = 1 ThenGetPlayerDirX = GetPlayerX(index)ElseIf GetPlayerDir(index) = 2 ThenGetPlayerDirX = GetPlayerX(index) - 1ElseIf GetPlayerDir(index) = 3 ThenGetPlayerDirX = GetPlayerX(index) + 1End IfEnd Function'Returns the Y of the tile in front of the playerFunction GetPlayerDirY(index)If GetPlayerDir(index) = 0 ThenGetPlayerDirY = GetPlayerY(index) - 1ElseIf GetPlayerDir(index) = 1 ThenGetPlayerDirY = GetPlayerY(index) + 1ElseIf GetPlayerDir(index) = 2 ThenGetPlayerDirY = GetPlayerY(index)ElseIf GetPlayerDir(index) = 3 ThenGetPlayerDirY = GetPlayerY(index)End IfEnd FunctionTo 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 More sharing options...
Squiddle Posted February 12, 2009 Author Share Posted February 12, 2009 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 IfEnd Sub``` Link to comment Share on other sites More sharing options...
Agoraphobic Posted February 12, 2009 Share Posted February 12, 2009 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 IfEnd Sub``` Link to comment Share on other sites More sharing options...
DrNova Posted February 12, 2009 Share Posted February 12, 2009 he just needs to use the getplayerdir calls via variables in the location parts of the call spell anim.simple Link to comment Share on other sites More sharing options...
Squiddle Posted February 12, 2009 Author Share Posted February 12, 2009 That one doesn't work either =/. Nova I tried using those (See the code I posted above) but nothing shows up =(. Link to comment Share on other sites More sharing options...
Agoraphobic Posted February 12, 2009 Share Posted February 12, 2009 Very strange, I just tested it works perfectly and had friend log on and works perfectly with 2 people on. If you don't mind upload your main and I'll take a look at it for you or I'm sure Nova would as well. Link to comment Share on other sites More sharing options...
DrNova Posted February 12, 2009 Share Posted February 12, 2009 Add those functions to your main.txtCall SpellAnim(SpellNum, getplayermap(jndex), GetPlayerDirX(index), GetPlayerDirY(index))Its simple. Link to comment Share on other sites More sharing options...
Squiddle Posted February 12, 2009 Author Share Posted February 12, 2009 Ummm, spell number? As if in you must make a spell first or do you mean you must draw the spell? I only drew it, never made the spell ^.^". I just added it, works now -.-. Thanks you two, you helped me a lot ^.^. Link to comment Share on other sites More sharing options...
Agoraphobic Posted February 12, 2009 Share Posted February 12, 2009 Create the spell for number 1 and give it the animation then try your script. 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