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

Script Question (i Think you know) [SOLVED]


BugSICK
 Share

Recommended Posts

i found a script trough surfing a month ago, but i cant find it right now, its a spell animation on npc death. anybody knows?
and correct me on this please.

```
Call SpellAnim(6, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
```
the spell animation is random on the map, how can i correct it. thanks
Link to comment
Share on other sites

SHoulnt it be:
```
Call SpellAnim(6, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetNpcY(GetPlayerMap(index), npcnum))
```Instead of The Players Y position it should be the NPC's Y position sicne its an animation on the NPC not the players, Hence if you put NpcY and then Player X you will get teh spell anim at a random point depending on both the players and the Npcs Position.
Link to comment
Share on other sites

Warning - while you were reading a new reply has been posted. You may wish to review your post. (Dammnit! lol)

Goes under Sub OnAttack(Index, Damage). Under the current stuff already in there.
.::..::..::..::..::..::.
Dim npcnum
npcnum = GetPlayerTargetNPC(Index)

If GetMapNpcHP(GetPlayerMap(Index), npcnum) < 1 Then
  If GetPlayerDir(index) = 0 Then
      Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetNpcY(GetPlayerMap(index), npcnum))
  End If
Else
End If

If GetMapNpcHP(GetPlayerMap(Index), npcnum) < 1 Then
  If GetPlayerDir(index) = 1 Then
      Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetNpcY(GetPlayerMap(index), npcnum))
  End If
Else
End If

If GetMapNpcHP(GetPlayerMap(Index), npcnum) < 1 Then
  If GetPlayerDir(index) = 2 Then
      Call SpellAnim(1, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
  End If
Else
End If

If GetMapNpcHP(GetPlayerMap(Index), npcnum) < 1 Then
  If GetPlayerDir(index) = 3 Then
      Call SpellAnim(1, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
  End If
Else
End If

End Sub
'Dont bother adding the End Sub above! You only need one. its just to give you an idea where the script would go
.::..::..::..::..::..::.
Change the orange numbers to the Spell Animation Number of course

Each animation will play if all requirements are met. The requirements are the player direction. (There is one for each direction so itll always be met) And that the NPCs health is below 1\. Which only leaves 0 which means dead… so it should play when u pwn the npc.
I didnt test it but it looks like itll work.
I know you only asked for the 1 line lol but i quickly found the player attack animation that mr miguu made, and i turned it into this so didnt take me long.
Link to comment
Share on other sites

Greendude120's has a better chance of succeeding, as I think the OnNpcDeath sub executes after the NPC has died, which means he will no longer have an X or Y on the map.

Though he doesn't need the "Else" in his If-Then statement, and he could just do:
```
If GetMapNpcHP(GetPlayerMap(Index), npcnum) < 1 Then
  If GetPlayerDir(index) = 0 Then
      Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetNpcY(GetPlayerMap(index), npcnum))
  End If

  If GetPlayerDir(index) = 1 Then
      Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetNpcY(GetPlayerMap(index), npcnum))
  End If

  If GetPlayerDir(index) = 2 Then
      Call SpellAnim(1, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
  End If

  If GetPlayerDir(index) = 3 Then
      Call SpellAnim(1, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
  End If
End If
```Or even better,
```
If GetMapNpcHP(GetPlayerMap(Index), npcnum) < 1 Then
  Select Case GetPlayerDir(Index)
      Case 0
        Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetNpcY(GetPlayerMap(index), npcnum))
      Case 1
        Call SpellAnim(1, GetPlayerMap(index), GetPlayerX(index), GetNpcY(GetPlayerMap(index), npcnum))
      Case 2
        Call SpellAnim(1, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
      Case 3
        Call SpellAnim(1, GetPlayerMap(index), GetNpcX(GetPlayerMap(index), npcnum), GetPlayerY(index))
  End Select
End If
```These would require less computation atleast.

Though, both codes seem abit unstable.

Warning - while you were typing a new reply has been posted. You may wish to review your post.
@BugSICK:

> i tried your code still its random, some appeared in me and some in NPC and sometimes doenst appeared. and if i move the death animation moves too.  :cry:

Give me afew; I'll see if I can work something out.

Warning - while you were typing a new reply has been posted. You may wish to review your post.
Depending on the direction the player faces, it looks like you're using the player's X or Y; in theory, if the player moves before the spell animation players, it will move in relation to where the player moved, and not on the NPC.
Link to comment
Share on other sites

Yea im not familiar with Cases and case select but that one by admiral looks good.

Also i think i know what ur problem is. I just got my client and server unsynced (cause of the map freeze bug) and i attacked an npc but the animation was on my char cause of the unsync. so maybe thats what happening to you?
Link to comment
Share on other sites

Okay, this should work; just throw it into your OnNpcDeath; it seems to execute before killing the NPCs:
```
Call SpellAnim(1, Map, GetNpcX(Map, NPCIndex), GetNpcY(Map, NPCIndex))

```Of course, replace "1" with the spell's number.

EDIT: Incase anyone wants to know what the problem was (incase it isn't obvious), GetNpcX takes in two values: The NPC's map, and the NPC's Index on that map.  You guys (excluding Greendude) were passing the NPC's number in; you needed to pass the index (luckily, the map and NPC index are passed into OnNpcDeath XD)
Link to comment
Share on other sites

@Bloodmyst:

> Admiral thats excatly what i said to him…. But mine was ignored by both Greendude and and yourself

Please read my "Edit".
You were passing in "npcnum" not "npcindex".
(also, you didn't have to GetPlayerMap, as "Map" is already passed though, and better, it's the NPC's map, not the player's map)
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...