Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spell animations fix when target dies
#1
Well as you may have noticed, if you kill a player or NPC with a spell and that target dies, the spell animation appears in the top left. To fix this we need to kill the player / npc AFTER you send the animation data. To do this it's simple:

Server side:

Find:

Code:
Public Sub CastSpell(ByVal Index As Long, ByVal SpellSlot As Long)
Dim SpellNum As Long
Dim MPReq As Long
Dim i As Long
Dim n As Long
Dim Damage As Long
Dim Casted As Boolean
Dim CanCast As Boolean
Dim ErrorMessage As String
Dim TargetType As Byte
Dim TargetName As String

Under add:

Code:
Damage = -1

Find (Sub CastSpell):

Code:
If Damage > 0 Then
                                    Call AttackPlayer(Index, n, Damage)
                                Else
                                    Call PlayerMsg(Index, "The spell was to weak to hurt " & GetPlayerName(n) & "!", BrightRed)
                                End If

And remove it. Then find (Sub CastSpell):

Code:
If Damage > 0 Then
                            Call AttackNpc(Index, n, Damage)
                        Else
                            Call PlayerMsg(Index, "The spell was to weak to hurt " & Trim$(Npc(MapNpc(GetPlayerMap(Index), n).Num).Name) & "!", BrightRed)
                        End If

And remove it. Find:

Find:

Code:
Damage = (GetPlayerStat(Index, Stats.Magic) \ 4) + Spell(SpellNum).Data1 - GetPlayerProtection(n)

Under add:

Code:
If Damage < 0 Then Damage = 0

Find:

Code:
Damage = (GetPlayerStat(Index, Stats.Magic) \ 4) + Spell(SpellNum).Data1 - (Npc(MapNpc(GetPlayerMap(Index), n).Num).Stat(Stats.Defense) \ 2)

Under add:

Code:
If Damage < 0 Then Damage = 0

Find:

Code:
Call SendDataToMap(GetPlayerMap(Index), SCastSpell & SEP_CHAR & TargetType & SEP_CHAR & n & SEP_CHAR & SpellNum & END_CHAR)

Under add:

Code:
If Damage  -1 Then
            Select Case TargetType
            
                Case TARGET_TYPE_PLAYER
                    If Damage > 0 Then
                        Call AttackPlayer(Index, n, Damage)
                    Else
                        Call PlayerMsg(Index, "The spell was to weak to hurt " & TargetName & "!", BrightRed)
                    End If
                
                Case TARGET_TYPE_NPC
                    If Damage > 0 Then
                        Call AttackNpc(Index, n, Damage)
                    Else
                        Call PlayerMsg(Index, "The spell was to weak to hurt " & TargetName & "!", BrightRed)
                    End If
            
            End Select
        End If

That should be it Big Grin I'm in a hurry...gotta go in 5 minutes. So if anybody has any problems post Big Grin
Reply
#2
Works.

To fix another bug, change:

Code:
The spell was to weak to hurt

To:

Code:
The spell was too weak to hurt

;D
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#3
Not a bug, that's a grammar mistake..
Reply
#4
Just realised this won't work ;D

It'll now try and attack a player no matter what spell you use.

Marked it as broken so no one uses it whilst you're away, because they might not no where to put the original code back ;D
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#5
Fixed.
Reply
#6
Ironic. The fix was fixed.
Reply
#7
Hopefully the fix that was fixed, doesn't need fixed.
Reply
#8
if it needed a new fix, then the fix that was fixed and requires a new fix, would have to be re-broken.
Reply
#9
Pbcrazy Wrote:if it needed a new fix, then the fix that was fixed and requires a new fix, would have to be re-broken.

Shut up. You suck.
Reply
#10
wut
Reply
#11
I've never seen it blit in the top right, however, I know if you kill an npc, it will still have the animation on it when it respawns. To fix that, client side, in Sub HandleSpawnNpc, at the bottom, add this:

Code:
For i = 1 To MAX_SPELLANIM
        MapNpc(n).SpellAnimations(i).SpellNum = 0
     Next
Reply
#12
Oh I meant to the top left. Because before it did the attacking before the animation, so if the NPC died it's position would be 0x 0y so I moved it to after.
Reply
#13
GIAKEN Wrote:Oh I meant to the top left. Because before it did the attacking before the animation, so if the NPC died it's position would be 0x 0y so I moved it to after.

I never see it up there either. O.o
Reply
#14
Oh...well maybe it was just for my engine. I did the animation system differently...not based on Player or NPC.
Reply
#15
GIAKEN Wrote:Oh...well maybe it was just for my engine. I did the animation system differently...not based on Player or NPC.

Maybe. My fix I posted is still useful. Without it, the npc will spawn and the animation will play out once.
Reply
#16
maybe its me but when i open the /editspell i get a error 9 or w/e with

Code:
Private Sub scrlFrame_Change()
    lblFrameNum.Caption = scrlFrame.Value
    Call SpellEditorBltSpell
    frmSpellEditor.scrlFrame.Max = (DDS_Spell(scrlFrame.Value).SurfDescription.lWidth \ SIZE_X) - 1
End Sub
Reply
#17
DDS_Spell(scrlFrame.Value)

scrlFrame.Value is exceeding the DDS_Spell's limits.

I haven't looked at the newest MS4, but find:

DDS_Spell(1 To

Not sure what it's set as, but make sure that the scroll bar's max doesn't go over the max value DDS_Spell can hold.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)