Mirage Source
Spell animations fix when target dies - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51)
+----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44)
+------ Forum: Bugs Reports (https://mirage-engine.uk/forums/forumdisplay.php?fid=9)
+------ Thread: Spell animations fix when target dies (/showthread.php?tid=2595)



Spell animations fix when target dies - GIAKEN - 03-03-2009

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


Re: Spell animations fix when target dies - Robin - 03-03-2009

Works.

To fix another bug, change:

Code:
The spell was to weak to hurt

To:

Code:
The spell was too weak to hurt

;D


Re: Spell animations fix when target dies - Matt - 04-03-2009

Not a bug, that's a grammar mistake..


Re: Spell animations fix when target dies - Robin - 04-03-2009

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


Re: [fixed] Spell animations fix when target dies - GIAKEN - 04-03-2009

Fixed.


Re: [fixed] Spell animations fix when target dies - Tony - 04-03-2009

Ironic. The fix was fixed.


Re: [fixed] Spell animations fix when target dies - Matt - 04-03-2009

Hopefully the fix that was fixed, doesn't need fixed.


Re: [fixed] Spell animations fix when target dies - Pbcrazy - 04-03-2009

if it needed a new fix, then the fix that was fixed and requires a new fix, would have to be re-broken.


Re: [fixed] Spell animations fix when target dies - Matt - 04-03-2009

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.


Re: [fixed] Spell animations fix when target dies - GIAKEN - 04-03-2009

wut


Re: Spell animations fix when target dies - Matt - 17-03-2009

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



Re: Spell animations fix when target dies - GIAKEN - 17-03-2009

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.


Re: Spell animations fix when target dies - Matt - 17-03-2009

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


Re: Spell animations fix when target dies - GIAKEN - 17-03-2009

Oh...well maybe it was just for my engine. I did the animation system differently...not based on Player or NPC.


Re: Spell animations fix when target dies - Matt - 17-03-2009

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.


Re: Spell animations fix when target dies - Avarit - 06-04-2009

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



Re: Spell animations fix when target dies - GIAKEN - 06-04-2009

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.