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

How to add arrows and slash animation?


Pallash
 Share

Recommended Posts

Not exactly sure what you want but if you want an animation that plays each time you hit an NPC or player with a sword or arrow you could do it like this:

Find:
```
Sub OnAttack(Index, Damage)

```
Find the snippet below and add the call spellanim line and exchagne SpellNo with the spellnumber that holds the slash animation. And do the same for the OnArrowHit sub.
Don't have the scripting file infront of me so don't remeber exactly what it looks like.

```
If Int(Damage) > 0 Then
      If Int(GetPlayerTarget(Index)) > 0 Then
              Target = GetPlayerTarget(Index)
              Call SpellAnim(SpellNo, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target)
              Call DamagePlayer(Index, Target, Damage)
      Else

```
This will add an animation that plays each time your damage is above 0\. If you want a "miss" or equal add an Else Case to the "If Int(Damage) > 0" condition and do another Call SpellAnim but with the spellnumber of a missanimation.

Donno if it was this you were looking for, if it was you can post here and I can post the entire attacksub with the changes when I get home.
Link to comment
Share on other sites

yea i want to add a slash animation if i hit a npc or also a enemy
and yeah i wanna add a arrow animation like:
if bowman atks he shot arrows

but what do i do with the scripting text? i have no clue about scripting  :cry:
Link to comment
Share on other sites

Well you should read alittle about spellanimation (think there is an excellent tutorial for that somewhere here) if you want them to work.
But let's assume that you use Spell 1 as animation for slash and spell 2 as animation for Arrowhit.

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

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

Sub OnArrowHit(Index, Damage)
Dim Target

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

```
And replace the entire sub with:
With the entire sub I mean everything you see in the box above (tbh it's even 2 subs and not one ;)).

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

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Call SpellAnim(1, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Call SpellAnim(1, GetPlayerMap(Index), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
End If
End Sub

Sub OnArrowHit(Index, Damage)
Dim Target

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Call SpellAnim(2, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Call SpellAnim(2, GetPlayerMap(Target), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
End If
End Sub

```
And if you want a miss animation or rather an animation that plays if you do 0 or less damage add the code below.
NOTES: Threw in alittle edit aswell where all damage below 0 will display 0 instead of -14, -10 etc etc….
The below script assumes that you use spell 3 as miss for melee, and spell 4 as miss for arrows.

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

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Call SpellAnim(1, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Call SpellAnim(1, GetPlayerMap(Index), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
        Else
                If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Damage = 0
                        Call SpellAnim(3, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Damage = 0
                        Call SpellAnim(3, GetPlayerMap(Index), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
End If
End Sub

Sub OnArrowHit(Index, Damage)
Dim Target

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Call SpellAnim(2, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Call SpellAnim(2, GetPlayerMap(Target), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
Else
                If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Damage = 0
                        Call SpellAnim(4, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Damage = 0
                        Call SpellAnim(4, GetPlayerMap(Index), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
        End If
End Sub

```
Hope that this helps you.

EDIT:
Just to make this script alittle bit cooler (or atleast in my opinion) you could do a randomized slash animation aswell.
Let's say you make 3 different slash animation (1-3 in the spelleditor) and 3 different arrowhot animations (4-6 in the spelleditor) Misses in the below code will be 7 for melee and 8 for arrows.

```
' Executes when a player presses the CONTROL key.
Sub OnAttack(Index, Damage)
Dim Target
        Dim RndRoll
If Int(Damage) > 0 Then
                RndRoll = rand(1,3)
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Call SpellAnim(RndRoll, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Call SpellAnim(RndRoll, GetPlayerMap(Index), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
        Else
                If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Damage = 0
                        Call SpellAnim(7, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Damage = 0
                        Call SpellAnim(7, GetPlayerMap(Index), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
End If
End Sub

Sub OnArrowHit(Index, Damage)
Dim Target
        Dim RndRoll
If Int(Damage) > 0 Then
                RndRoll = rand(4,6)
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Call SpellAnim(RndRoll, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Call SpellAnim(RndRoll, GetPlayerMap(Target), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
Else
                If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Damage = 0
                        Call SpellAnim(8, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Damage = 0
                        Call SpellAnim(8, GetPlayerMap(Index), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
        End If
End Sub

```
This will display a random spellanimation between 1-3 when you hit melee and 4-6 when you hit with arrows. Sorry if I spam code, but takes alot of place when pasting full subs. And once again hope that this solves your problem and that you find it useful.
Link to comment
Share on other sites

No .ini data needed

Open your Main.txt and look for the code at the top of my post and then replace it with anyone of my 3 code boxes.

Log in to your game as an administrator. Type /editspells (or /editspell can't remeber).

Choose spell 1 (The one that says 1: ). Here you don't need to enter anything, skip to the animation part. Here you will select the first slash animation (What you want it to show when you hit with melee). Do the same for 2: and 3: and here enter different animations for a slash. I think there is like 3-4 different slash animations in the basic animationdb that comes with eclipse. Do the same with 4: - 6: but here you choose the animations you want to play when an arrow hits.

Then you choose 7: here you wil enter a miss animation for melee. And at 8: enter a miss animation for arrow miss.

You can name them "Slashanim1", "Slashanim2" and so on, the name doesn't really matter.

Then copy/paste the code below into your Main.txt (located in server\Scripts). Use the search function and find Sub OnAttack and select it all down to the place (like 10 lines down) where it says End Sub. Replace that code with the code below
```
' Executes when a player presses the CONTROL key.
Sub OnAttack(Index, Damage)
Dim Target
        Dim RndRoll
If Int(Damage) > 0 Then
                RndRoll = rand(1,3)
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Call SpellAnim(RndRoll, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Call SpellAnim(RndRoll, GetPlayerMap(Index), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
        Else
                If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Damage = 0
                        Call SpellAnim(7, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Damage = 0
                        Call SpellAnim(7, GetPlayerMap(Index), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
End If
End Sub

```
Then do the same but instead search for Sub OnArrowHit (should be directly below). And replace that whole thing to End Sub with the code below:
```
Sub OnArrowHit(Index, Damage)
Dim Target
        Dim RndRoll
If Int(Damage) > 0 Then
                RndRoll = rand(4,6)
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Call SpellAnim(RndRoll, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Call SpellAnim(RndRoll, GetPlayerMap(Target), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
Else
                If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
                        Damage = 0
                        Call SpellAnim(8, GetPlayerMap(Target), GetPlayerX(Target), GetPlayerY(Target))
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
                        Damage = 0
                        Call SpellAnim(8, GetPlayerMap(Index), GetNPCX(GetPlayerMap(Index), Target), GetNPCY(GetPlayerMap(Index), Target))
Call DamageNPC(Index, Target, Damage)
End If
        End If
End Sub

```
I donno how to explain it any easier. If you still have trouble installing this with these guidelines I'd recommend you to read some very very basic scripting tutorials since this code is very easy to install.
Feel free to ask any questions you have but please try this first before asking. If you can't get it to work I'll be happy to try and answer your questions to the best of my ability :)

EDIT:
I'd recommend this tutorial (Credits to Squiddle for making it ;)) [http://www.touchofdeathforums.com/smf/index.php/topic,39867.0.html](http://www.touchofdeathforums.com/smf/index.php/topic,39867.0.html)

There is a Chapter 2 aswell. Might get you to learn the basics of scripting. Even when adding scripts you need to have at least a basic knowledge of how the Main.txt is built. My guess is that it will take you 10-20 mins to understand the structure. And after that you'll find it easy to add new scripts here from the forums.
Link to comment
Share on other sites

> uh.. for arrows.. try making a weapon.. and checking the "bow" button… then select an arrow...
> and for melee attacks just call an animation in "on attack" like mentioned above.

Making a weapon with the bow type isn't really the same as the script above. The bow type only makes the weapon fire ranged and thus blting an arrow travelling in the direction the player is facing (until hit or max range). The above code plays an animation on the target when the arrow hits, and if the arrow deals less then 1 dmg it plays another "miss" animation. Also it randomizes the animation played on hit. I have all custom animations in my game but if I remember it correctly there are like 3-5 different "slash" animations in Eclipse.

To make this script even cooler (once again in my opinion) I'd make a sourceedit adding a scrollbar to the itemeditor making a new type called like proficiency and make some types named like axe, sword etc etc, then edit the OnAttack to send that data to the script. Then you could have different animations depending on what type of weapon you are wielding.
Link to comment
Share on other sites

added, send your Main.txt through MSN and I'll add it.

But make sure to read the tutorials about scripting, that way you can easily read out what this code actually does and insert it correctly into the scripting file. Goes for all scripts ofc. Not just this one.
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...