Print Page | Close Window

Memorize Spell

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=132
Printed Date: 20 December 2006 at 5:52pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Memorize Spell
Posted By: Sync
Subject: Memorize Spell
Date Posted: 11 February 2006 at 2:41pm
Difficulty: Medium 3/5

Originaly Posted By: GodSentDeath

Wow... this took a whole 5 minutes :P

All Client Side

in the frmMirage code add:
Dim SpellMemorized As Long

at the top under Options Explicit.

Add the following anywhere:
Private Sub lstSpells_DblClick()
    If Player(MyIndex).Spell(lstSpells.ListIndex + 1) > 0 Then
        SpellMemorized = lstSpells.ListIndex + 1
        Call AddText("Successfully memorized spell!", White)
    Else
        Call AddText("No spell here to memorize.", BrightRed)
    End If
End Sub


Find Private Sub Form_KeyUp replace it all with:
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF1 Then
        If SpellMemorized > 0 Then
             If GetTickCount > Player(MyIndex).AttackTimer + 1000 Then
                 If Player(MyIndex).Moving = 0 Then
                     Call SendData("cast" & SEP_CHAR & SpellMemorized & SEP_CHAR & END_CHAR)
                     Player(MyIndex).Attacking = 1
                     Player(MyIndex).AttackTimer = GetTickCount
                     Player(MyIndex).CastedSpell = YES
                 Else
                     Call AddText("Cannot cast while walking!", BrightRed)
                 End If
             End If
        Else
             Call AddText("No spell here memorized.", BrightRed)
        End If
    Else
        Call CheckInput(0, KeyCode, Shift)
    End If
End Sub


Ok this should be basically it... When a player double clicks the spell he/she wants to memorize it will save it to SpellMemorized, and when they hit F1 and an npc is targeted it will cast the saved spell.

If you want it so when the player holds down the F1 key to cast the memorized spell then replace Private Sub Form_KeyDown with:
Private Sub picScreen_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim i As Long
    Call EditorMouseDown(Button, Shift, x, y)
    
    If Button = 1 And InEditor = False Then
        Call PlayerSearch(Button, Shift, x, y)
    End If
For i = 1 To MAX_MAP_NPCS
    If MapNpc(i).y = Int(y / PIC_Y) And MapNpc(i).x = Int(x / PIC_X) Then
        If InEditor = False And Button = 2 Then
             If SpellMemorized > 0 Then
                 If GetTickCount > Player(MyIndex).AttackTimer + 1000 Then
                     If Player(MyIndex).Moving = 0 Then
                           Call SendData("cast" & SEP_CHAR & SpellMemorized & SEP_CHAR & END_CHAR)
                           Player(MyIndex).Attacking = 1
                           Player(MyIndex).AttackTimer = GetTickCount
                           Player(MyIndex).CastedSpell = YES
                     Else
                           Call AddText("Cannot cast while walking!", BrightRed)
                     End If
                 End If
             Else
                 Call AddText("No spell memorized.", BrightRed)
             End If
        End If
    End If
Next i
End Sub


Thats All!

[edit]
Right Click To Cast Spell

In the frmMirage code find Private Sub picScreen_MouseDown replace it all with:

Private Sub picScreen_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    Call EditorMouseDown(Button, Shift, x, y)

    If Button = 1 And InEditor = False Then
        Call PlayerSearch(Button, Shift, x, y)
    End If

    If InEditor = False And Button = 2 Then
        If SpellMemorized > 0 Then
             If GetTickCount > Player(MyIndex).AttackTimer + 1000 Then
                 If Player(MyIndex).Moving = 0 Then
                     Call SendData("cast" & SEP_CHAR & SpellMemorized & SEP_CHAR & END_CHAR)
                     Player(MyIndex).Attacking = 1
                     Player(MyIndex).AttackTimer = GetTickCount
                     Player(MyIndex).CastedSpell = YES
                 Else
                     Call AddText("Cannot cast while walking!", BrightRed)
                 End If
             End If
        Else
             Call AddText("No spell memorized.", BrightRed)
        End If
    End If
End Sub


Now you must target the enemy first by using the left click button, and right click will cast the memorized spell

[edit2]I changed the Right Click Spell code because I noticed you can click anywhere to attack, now its just when you click them



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info