Print Page | Close Window

Drop System

Printed From: Mirage Source
Category: Tutorials
Forum Name: Submitted Tutorials
Forum Discription: Tutorial submissions for MSE are posted here, waiting for approval
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=267
Printed Date: 20 December 2006 at 6:04pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Drop System
Posted By: Dark Echo
Subject: Drop System
Date Posted: 16 February 2006 at 4:28am
Okay, since a lot more people are moving to Mirage Source from Elysium. They are quickly working out that not all the cool features in Elysium are in Mirage Source. One of those cool features, that GSD added in was the multi drop feature for npcs. Now, i've decided to make my own multi drop feature just for MSE. You can still get this to work with 303, but you would need to work that out on your own.
Now, before i start the tutorial i would just like to explain how this works. I changed the NPC drop system in MSE so instead of you choosing a specific item, value and chance you choose what type of drop combination you would like to use. Meaning drops are saved in a separate file from npcs. This way drop combinations can be used over and over again without the need to remake them. Now, this would mean you would need to make a drop editor and edit the npc editor slightly.

Tutorial Diffculty: 1/5

Easy, just a plain copy and paste tutorial. Sorry for those who want comments, i'll promise i'll comment this sometime later this year. Sorry people..

Part 1 - Server Side
Go into modConstants and add at the bottom:
' Drop constants
Public Const MAX_DROPS = 255
Public Const MAX_DROP_ITEMS = 10


Go into modDatabase and add:
Sub SaveDrop(ByVal DropNum As Long)
Dim FileName As String
Dim i As Long

    FileName = App.Path & "\Data\drops.ini"
  
    Call PutVar(FileName, "DROP" & DropNum, "Name", Trim(Drop(DropNum).Name))
   
    For i = 1 To MAX_DROP_ITEMS
        Call PutVar(FileName, "DROP" & DropNum, "ItemNum" & i, Trim(Drop(DropNum).ItemDrop(i).ItemNum))
        Call PutVar(FileName, "DROP" & DropNum, "Chance" & i, Trim(Drop(DropNum).ItemDrop(i).Chance))
        Call PutVar(FileName, "DROP" & DropNum, "ItemValue" & i, Trim(Drop(DropNum).ItemDrop(i).ItemValue))
    Next i
End Sub

Sub SaveDrops()
Dim i As Long

    For i = 1 To MAX_DROPS
        Call SaveDrop(i)
    Next i
End Sub

Sub LoadDrops()
Dim FileName As String
Dim i As Long, ii As Long

    Call CheckDrops
  
    FileName = App.Path & "\Data\drops.ini"
  
    For i = 1 To MAX_DROPS
        Drop(i).Name = Trim(GetVar(FileName, "DROP" & i, "Name"))
   
        For ii = 1 To MAX_DROP_ITEMS
         &nbs p;  Drop(i).ItemDrop(ii).ItemNum = Val(GetVar(FileName, "DROP" & i, "ItemNum" & ii))
         &nbs p;  Drop(i).ItemDrop(ii).Chance = Val(GetVar(FileName, "DROP" & i, "Chance" & ii))
         &nbs p;  Drop(i).ItemDrop(ii).ItemValue = Val(GetVar(FileName, "DROP" & i, "ItemValue" & ii))
      
         &nbs p;  DoEvents
        Next ii
    Next i
End Sub

Sub CheckDrops()
    If Not FileExist("Data\drops.ini") Then
        Call SaveDrops
    End If
End Sub


Find and change to:
Sub SaveNpc(ByVal NpcNum As Long)
Dim FileName As String

    FileName = App.Path & "\data\npcs.ini"
   
    Call PutVar(FileName, "NPC" & NpcNum, "Name", Trim(Npc(NpcNum).Name))
    Call PutVar(FileName, "NPC" & NpcNum, "AttackSay", Trim(Npc(NpcNum).AttackSay))
    Call PutVar(FileName, "NPC" & NpcNum, "Sprite", Trim(Npc(NpcNum).Sprite))
    Call PutVar(FileName, "NPC" & NpcNum, "SpawnSecs", Trim(Npc(NpcNum).SpawnSecs))
    Call PutVar(FileName, "NPC" & NpcNum, "Behavior", Trim(Npc(NpcNum).Behavior))
    Call PutVar(FileName, "NPC" & NpcNum, "Range", Trim(Npc(NpcNum).Range))
    Call PutVar(FileName, "NPC" & NpcNum, "Drop", Trim(Npc(NpcNum).Drop))
    Call PutVar(FileName, "NPC" & NpcNum, "STR", Trim(Npc(NpcNum).STR))
    Call PutVar(FileName, "NPC" & NpcNum, "DEF", Trim(Npc(NpcNum).DEF))
    Call PutVar(FileName, "NPC" & NpcNum, "SPEED", Trim(Npc(NpcNum).SPEED))
    Call PutVar(FileName, "NPC" & NpcNum, "MAGI", Trim(Npc(NpcNum).MAGI))
End Sub

Sub LoadNpcs()
On Error Resume Next

Dim FileName As String
Dim i As Long

    Call CheckNpcs
   
    FileName = App.Path & "\data\npcs.ini"
   
    For i = 1 To MAX_NPCS
        Npc(i).Name = GetVar(FileName, "NPC" & i, "Name")
        Npc(i).AttackSay = GetVar(FileName, "NPC" & i, "AttackSay")
        Npc(i).Sprite = GetVar(FileName, "NPC" & i, "Sprite")
        Npc(i).SpawnSecs = GetVar(FileName, "NPC" & i, "SpawnSecs")
        Npc(i).Behavior = GetVar(FileName, "NPC" & i, "Behavior")
        Npc(i).Range = GetVar(FileName, "NPC" & i, "Range")
        Npc(i).Drop = GetVar(FileName, "NPC" & i, "Drop")
        Npc(i).STR = GetVar(FileName, "NPC" & i, "STR")
        Npc(i).DEF = GetVar(FileName, "NPC" & i, "DEF")
        Npc(i).SPEED = GetVar(FileName, "NPC" & i, "SPEED")
        Npc(i).MAGI = GetVar(FileName, "NPC" & i, "MAGI")
   
        DoEvents
    Next i
End Sub


Go into modgameLogic and add:
Sub ClearDrop(ByVal Index As Long)
Dim i As Long

    Drop(Index).Name = ""
       
    For i = 1 To MAX_DROP_ITEMS
        Drop(Index).ItemDrop(i).ItemNum = 0
        Drop(Index).ItemDrop(i).Chance = 0
        Drop(Index).ItemDrop(i).ItemValue = 0
    Next i
End Sub

Sub ClearDrops()
Dim i As Long

    For i = 1 To MAX_DROPS
        Call ClearDrop(i)
    Next i
End Sub


Go into Sub AttackNpc and find:
Dim Name As String
Dim Exp As Long
Dim n As Long, i As Long
Dim STR As Long, DEF As Long, MapNum As Long, NpcNum As Long


Make it so it looks like this:
Dim Name As String
Dim Exp As Long
Dim n As Long, i As Long
Dim STR As Long, DEF As Long, MapNum As Long, NpcNum As Long, DropNum As Long


Find:
        ' Drop the goods if they get it
        n = Int(Rnd * Npc(NpcNum).DropChance) + 1
        If n = 1 Then
         &nbs p;  Call SpawnItem(Npc(NpcNum).DropItem, Npc(NpcNum).DropItemValue, MapNum, MapNpc(MapNum, MapNpcNum).x, MapNpc(MapNum, MapNpcNum).y)
        End If


Make it so it looks like this:
        ' Drop the goods if they get it
        DropNum = Npc(NpcNum).Drop
         &nbs p;     
        For i = 1 To MAX_DROP_ITEMS
         &nbs p;  n = Int(Rnd * Drop(DropNum).ItemDrop(i).Chance) + 1
         &nbs p;  If n = 1 Then
         &nbs p;      Call SpawnItem(Drop(DropNum).ItemDrop(i).ItemNum, Drop(DropNum). ItemDrop(i).ItemValue, MapNum, MapNpc(MapNum, MapNpcNum).x, MapNpc(MapNum, MapNpcNum).y)
         &nbs p;  End If
        Next i


Find and change to:
Sub ClearNpc(ByVal Index As Long)
    Npc(Index).Name = ""
    Npc(Index).AttackSay = ""
    Npc(Index).Sprite = 0
    Npc(Index).SpawnSecs = 0
    Npc(Index).Behavior = 0
    Npc(Index).Range = 0
    Npc(Index).Drop = 0
    Npc(Index).STR = 0
    Npc(Index).DEF = 0
    Npc(Index).SPEED = 0
    Npc(Index).MAGI = 0
End Sub


Go into modGeneral and find:
    Call SetStatus("Clearing spells...")
    Call ClearSpells


Add below that this:
    Call SetStatus("Clearing drops...")
    Call ClearDrops


Find:
    Call SetStatus("Loading spells...")
    Call LoadSpells


Add below that this:
    Call SetStatus("Loading drops...")
    Call LoadDrops


Go into modGlobals and add:
Public Drop(1 To MAX_DROPS) As DropRec


Go into modHandleData and add:
Dim DropNum As Long


And add:
    ' ::::::::::::::::::::::::::::::
    ' :: Request edit drop packet ::
    ' ::::::::::::::::::::::::::::::
    If LCase(Parse(0)) = "requesteditdrop" Then
        ' Prevent hacking
        If GetPlayerAccess(Index) < ADMIN_DEVELOPER Then
         &nbs p;  Call HackingAttempt(Index, "Admin Cloning")
         &nbs p;  Exit Sub
        End If
      
        Call SendDataTo(Index, "DROPEDITOR" & SEP_CHAR & END_CHAR)
        Exit Sub
    End If
  
    ' ::::::::::::::::::::::
    ' :: Edit drop packet ::
    ' ::::::::::::::::::::::
    If LCase(Parse(0)) = "editdrop" Then
        ' Prevent hacking
        If GetPlayerAccess(Index) < ADMIN_DEVELOPER Then
         &nbs p;  Call HackingAttempt(Index, "Admin Cloning")
         &nbs p;  Exit Sub
        End If
      
        ' The drop #
        n = Val(Parse(1))
      
        ' Prevent hacking
        If n < 0 Or n > MAX_DROPS Then
         &nbs p;  Call HackingAttempt(Index, "Invalid Drop Index")
         &nbs p;  Exit Sub
        End If
      
        Call AddLog(GetPlayerName(Index) & " editing drop #" & n & ".", ADMIN_LOG)
        Call SendEditDropTo(Index, n)
    End If
  
    ' ::::::::::::::::::::::
    ' :: Save drop packet ::
    ' ::::::::::::::::::::::
    If (LCase(Parse(0)) = "savedrop") Then
        ' Prevent hacking
        If GetPlayerAccess(Index) < ADMIN_DEVELOPER Then
         &nbs p;  Call HackingAttempt(Index, "Admin Cloning")
         &nbs p;  Exit Sub
        End If
      
        ' Drop #
        DropNum = Val(Parse(1))
      
        ' Prevent hacking
        If n < 0 Or n > MAX_DROPS Then
         &nbs p;  Call HackingAttempt(Index, "Invalid Drop Index")
         &nbs p;  Exit Sub
        End If
      
        ' Update the drop
        Drop(DropNum).Name = Trim(Parse(2))
       
        n = 3
        For i = 1 To MAX_DROP_ITEMS
         &nbs p;  Drop(DropNum).ItemDrop(i).ItemNum = (Parse(n))
         &nbs p;  Drop(DropNum).ItemDrop(i).Chance = (Parse(n + 1))
         &nbs p;  Drop(DropNum).ItemDrop(i).ItemValue = (Parse(n + 2))
         &nbs p;  n = n + 3
        Next i
       
        ' Save it
        Call SendUpdateDropToAll(DropNum)
        Call SaveDrop(DropNum)
        Call AddLog(GetPlayerName(Index) & " saving drop #" & n & ".", ADMIN_LOG)
        Exit Sub
    End If


Find and change to:
    ' :::::::::::::::::::::
    ' :: Save npc packet ::
    ' :::::::::::::::::::::
    If LCase(Parse(0)) = "savenpc" Then
        ' Prevent hacking
        If GetPlayerAccess(Index) < ADMIN_DEVELOPER Then
         &nbs p;  Call HackingAttempt(Index, "Admin Cloning")
         &nbs p;  Exit Sub
        End If
       
        n = Val(Parse(1))
       
        ' Prevent hacking
        If n < 0 Or n > MAX_NPCS Then
         &nbs p;  Call HackingAttempt(Index, "Invalid NPC Index")
         &nbs p;  Exit Sub
        End If
       
        ' Update the npc
        Npc(n).Name = Parse(2)
        Npc(n).AttackSay = Parse(3)
        Npc(n).Sprite = Val(Parse(4))
        Npc(n).SpawnSecs = Val(Parse(5))
        Npc(n).Behavior = Val(Parse(6))
        Npc(n).Range = Val(Parse(7))
        Npc(n).Drop = Val(Parse(8))
        Npc(n).STR = Val(Parse(11))
        Npc(n).DEF = Val(Parse(12))
        Npc(n).SPEED = Val(Parse(13))
        Npc(n).MAGI = Val(Parse(14))
       
        ' Save it
        Call SendUpdateNpcToAll(n)
        Call SaveNpc(n)
        Call AddLog(GetPlayerName(Index) & " saved npc #" & n & ".", ADMIN_LOG)
        Exit Sub
    End If


Go into modServerTCP and add:
Sub SendDrops(ByVal Index As Long)
Dim i As Long

    For i = 1 To MAX_DROPS
        If Trim(Drop(i).Name) <> "" Then
         &nbs p;  Call SendUpdateDropTo(Index, i)
        End If
    Next i
End Sub

Sub SendUpdateDropToAll(ByVal DropNum As Long)
Dim Packet As String

    Packet = "UPDATEDROP" & SEP_CHAR & DropNum & SEP_CHAR & Trim(Drop(DropNum).Name) & SEP_CHAR & END_CHAR
    Call SendDataToAll(Packet)
End Sub

Sub SendUpdateDropTo(ByVal Index As Long, ByVal DropNum As Long)
Dim Packet As String

    Packet = "UPDATEDROP" & SEP_CHAR & DropNum & SEP_CHAR & Trim(Drop(DropNum).Name) & SEP_CHAR & END_CHAR
    Call SendDataTo(Index, Packet)
End Sub

Sub SendEditDropTo(ByVal Index As Long, ByVal DropNum As Long)
Dim Packet As String
Dim i As Long
   
    Packet = "EDITDROP" & SEP_CHAR & DropNum & SEP_CHAR & Drop(DropNum).Name & SEP_CHAR
   
    For i = 1 To MAX_DROP_ITEMS
        Packet = Packet & (Drop(DropNum).ItemDrop(i).ItemNum) & SEP_CHAR & Drop(DropNum).ItemDrop(i).Chance & SEP_CHAR & Drop(DropNum).ItemDrop(i).ItemValue & SEP_CHAR
    Next i
   
    Packet = Packet & END_CHAR
   
    Call SendDataTo(Index, Packet)
End Sub


Find and change to:
Sub SendEditNpcTo(ByVal Index As Long, ByVal NpcNum As Long)
Dim Packet As String

    Packet = "EDITNPC" & SEP_CHAR & NpcNum & SEP_CHAR & Trim(Npc(NpcNum).Name) & SEP_CHAR & Trim(Npc(NpcNum).AttackSay) & SEP_CHAR & Npc(NpcNum).Sprite & SEP_CHAR & Npc(NpcNum).SpawnSecs & SEP_CHAR & Npc(NpcNum).Behavior & SEP_CHAR & Npc(NpcNum).Range & SEP_CHAR & Npc(NpcNum).Drop & SEP_CHAR & Npc(NpcNum).STR & SEP_CHAR & Npc(NpcNum).DEF & SEP_CHAR & Npc(NpcNum).SPEED & SEP_CHAR & Npc(NpcNum).MAGI & SEP_CHAR & END_CHAR
    Call SendDataTo(Index, Packet)
End Sub


Go into modTypes and find:
Type MapItemRec
    Num As Byte
    Value As Long
    Dur As Integer
   
    x As Byte
    y As Byte
End Type


Add below that this (remove the old npc rec):
Type DropItemRec
    ItemNum As Byte
    Chance As Integer
    ItemValue As Integer
End Type

Type DropRec
    Name As String
    ItemDrop(1 To MAX_DROP_ITEMS) As DropItemRec
End Type

Type NpcRec
    Name As String * NAME_LENGTH
    AttackSay As String * 255
   
    Sprite As Integer
    SpawnSecs As Long
    Behavior As Byte
    Range As Byte
   
    Drop As Byte
   
    STR  As Byte
    DEF As Byte
    SPEED As Byte
    MAGI As Byte
End Type


Part 2 - Client Side
Go into modClientTCP and add:
Sub SendRequestEditDrop()
Dim Packet As String

    Packet = "REQUESTEDITDROP" & SEP_CHAR & END_CHAR
    Call SendData(Packet)
End Sub

Public Sub SendSaveDrop(ByVal DropNum As Long)
Dim Packet As String
Dim i As Long

    With Drop(DropNum)
        Packet = "SAVEDROP" & SEP_CHAR & DropNum & SEP_CHAR & Trim(.Name) & SEP_CHAR
    End With
   
    For i = 1 To MAX_DROP_ITEMS
        With Drop(DropNum).ItemDrop(i)
         &nbs p;  Packet = Packet & .ItemNum & SEP_CHAR & .Chance & SEP_CHAR & .ItemValue & SEP_CHAR
        End With
    Next i
   
    Packet = Packet & END_CHAR
    Call SendData(Packet)
End Sub


Find and change to:
Public Sub SendSaveNpc(ByVal NpcNum As Long)
'********************************************************* *******
'* WHEN        WHO        WHAT
'* ----        ---        ----
'* 07/12/2005  Shannara   Optimized function.
'********************************************************* *******

Dim Packet As String
   
    With Npc(NpcNum)
        Packet = "SAVENPC" & SEP_CHAR & NpcNum & SEP_CHAR & Trim(.Name) & SEP_CHAR & Trim(.AttackSay) & SEP_CHAR & .Sprite & SEP_CHAR & .SpawnSecs & SEP_CHAR & .Behavior & SEP_CHAR & .Range & SEP_CHAR & .Drop & SEP_CHAR & .STR & SEP_CHAR & .DEF & SEP_CHAR & .SPEED & SEP_CHAR & .MAGI & SEP_CHAR & END_CHAR
    End With
   
    Call SendData(Packet)
End Sub


Go into modConstants and add:
' Drop constants
Public Const MAX_DROPS = 255
Public Const MAX_DROP_ITEMS = 10


Go into modGameLogic and find and change to:
Public Sub NpcEditorInit()
'********************************************************* *******
'* WHEN        WHO        WHAT
'* ----        ---        ----
'* 07/12/2005  Shannara   Added gfx constant.
'********************************************************* *******
   
    frmNpcEditor.picSprites.Picture = LoadPicture(App.Path & GFX_PATH & "sprites" & GFX_EXT)
   
    frmNpcEditor.txtName.Text = Trim(Npc(EditorIndex).Name)
    frmNpcEditor.txtAttackSay.Text = Trim(Npc(EditorIndex).AttackSay)
    frmNpcEditor.scrlSprite.Value = Npc(EditorIndex).Sprite
    frmNpcEditor.txtSpawnSecs.Text = STR(Npc(EditorIndex).SpawnSecs)
    frmNpcEditor.cmbBehavior.ListIndex = Npc(EditorIndex).Behavior
    frmNpcEditor.scrlRange.Value = Npc(EditorIndex).Range
    frmNpcEditor.scrlDrop.Value = Npc(EditorIndex).Drop
    frmNpcEditor.scrlSTR.Value = Npc(EditorIndex).STR
    frmNpcEditor.scrlDEF.Value = Npc(EditorIndex).DEF
    frmNpcEditor.scrlSPEED.Value = Npc(EditorIndex).SPEED
    frmNpcEditor.scrlMAGI.Value = Npc(EditorIndex).MAGI
   
    frmNpcEditor.Show vbModal
End Sub

Public Sub NpcEditorOk()
    Npc(EditorIndex).Name = frmNpcEditor.txtName.Text
    Npc(EditorIndex).AttackSay = frmNpcEditor.txtAttackSay.Text
    Npc(EditorIndex).Sprite = frmNpcEditor.scrlSprite.Value
    Npc(EditorIndex).SpawnSecs = Val(frmNpcEditor.txtSpawnSecs.Text)
    Npc(EditorIndex).Behavior = frmNpcEditor.cmbBehavior.ListIndex
    Npc(EditorIndex).Range = frmNpcEditor.scrlRange.Value
    Npc(EditorIndex).Drop = frmNpcEditor.scrlDrop.Value
    Npc(EditorIndex).STR = frmNpcEditor.scrlSTR.Value
    Npc(EditorIndex).DEF = frmNpcEditor.scrlDEF.Value
    Npc(EditorIndex).SPEED = frmNpcEditor.scrlSPEED.Value
    Npc(EditorIndex).MAGI = frmNpcEditor.scrlMAGI.Value
   
    Call SendSaveNpc(EditorIndex)
    InNpcEditor = False
    Unload frmNpcEditor
End Sub


Find:
             ' Editing spell request
         &nbs p;  If Mid(MyText, 1, 10) = "/editspell" Then
         &nbs p;      Call SendRequestEditSpell
         &nbs p;      MyText = ""
         &nbs p;      Exit Sub
         &nbs p;  End If


Add below that this:
             ' Editing drop request
         &nbs p;  If Mid(MyText, 1, 10) = "/editdrop" Then
         &nbs p;      Call SendRequestEditDrop
         &nbs p;      MyText = ""
         &nbs p;      Exit Sub
         &nbs p;  End If


Go into modGlobals and find:
Public EditorIndex As Long


Add below that this:
Public InDropEditor As Boolean


Find:
Public Spell(1 To MAX_SPELLS) As SpellRec


Add below that this:
Public Drop(1 To MAX_DROPS) As DropRec


Add at the bottom of modGameLogic:
Public Sub DropEditorInit()
    frmDropEditor.txtDropName.Text = Trim(Drop(EditorIndex).Name)
    frmDropEditor.scrlItemNum.Value = Drop(EditorIndex).ItemDrop(1).ItemNum
    frmDropEditor.txtChance.Text = Trim(Drop(EditorIndex).ItemDrop(1).Chance)
    frmDropEditor.scrlValue.Value = Drop(EditorIndex).ItemDrop(1).ItemValue
   
    frmDropEditor.Show vbModal
End Sub

Public Sub DropEditorOk()
    Drop(EditorIndex).Name = frmDropEditor.txtDropName.Text
  
    Call SendSaveDrop(EditorIndex)
    InDropEditor = False
    Unload frmDropEditor
End Sub

Public Sub DropEditorCancel()
    InDropEditor = False
    Unload frmDropEditor
End Sub


Go to modHandleData and add:
Dim DropNum As Long


And add:
    ' ::::::::::::::::::::::::
    ' :: Drop editor packet ::
    ' ::::::::::::::::::::::::
    If (LCase(Parse(0)) = "dropeditor") Then
        InDropEditor = True
       
        frmIndex.Show
        frmIndex.lstIndex.Clear
       
        ' Add the names
        For i = 1 To MAX_DROPS
         &nbs p;  frmIndex.lstIndex.AddItem i & ": " & Trim(Drop(i).Name)
        Next i
       
        frmIndex.lstIndex.ListIndex = 0
        Exit Sub
    End If
   
    ' ::::::::::::::::::::::::
    ' :: Update drop packet ::
    ' ::::::::::::::::::::::::
    If (LCase(Parse(0)) = "updatedrop") Then
        n = Val(Parse(1))
       
        ' Update the drop
        Drop(n).Name = Parse(2)
        Exit Sub
    End If

    ' ::::::::::::::::::::::
    ' :: Edit drop packet :: <- Used for item editor admins only
    ' ::::::::::::::::::::::
    If (LCase(Parse(0)) = "editdrop") Then
        DropNum = Val(Parse(1))
       
        ' Update the drop
        Drop(DropNum).Name = Parse(2)
       
        n = 3
       
        For i = 1 To MAX_DROP_ITEMS
         &nbs p;  Drop(DropNum).ItemDrop(i).ItemNum = Val(Parse(n))
         &nbs p;  Drop(DropNum).ItemDrop(i).Chance = Val(Parse(n + 1))
         &nbs p;  Drop(DropNum).ItemDrop(i).ItemValue = Val(Parse(n + 2))
         &nbs p;  n = n + 3
        Next i
       
        ' Initialize the drop editor
        Call DropEditorInit

        Exit Sub
    End If


Find and change:
    ' :::::::::::::::::::::::
    ' :: Update npc packet ::
    ' :::::::::::::::::::::::
    If (LCase(Parse(0)) = "updatenpc") Then
        n = Val(Parse(1))
       
        ' Update the item
        Npc(n).Name = Parse(2)
        Npc(n).AttackSay = ""
        Npc(n).Sprite = Val(Parse(3))
        Npc(n).SpawnSecs = 0
        Npc(n).Behavior = 0
        Npc(n).Range = 0
        Npc(n).Drop = 0
        Npc(n).STR = 0
        Npc(n).DEF = 0
        Npc(n).SPEED = 0
        Npc(n).MAGI = 0
        Exit Sub
    End If

    ' :::::::::::::::::::::
    ' :: Edit npc packet :: <- Used for item editor admins only
    ' :::::::::::::::::::::
    If (LCase(Parse(0)) = "editnpc") Then
        n = Val(Parse(1))
       
        ' Update the npc
        Npc(n).Name = Parse(2)
        Npc(n).AttackSay = Parse(3)
        Npc(n).Sprite = Val(Parse(4))
        Npc(n).SpawnSecs = Val(Parse(5))
        Npc(n).Behavior = Val(Parse(6))
        Npc(n).Range = Val(Parse(7))
        Npc(n).Drop = Val(Parse(8))
        Npc(n).STR = Val(Parse(9))
        Npc(n).DEF = Val(Parse(10))
        Npc(n).SPEED = Val(Parse(11))
        Npc(n).MAGI = Val(Parse(12))
       
        ' Initialize the npc editor
        Call NpcEditorInit

        Exit Sub
    End If


Go into modTypes and find:
Type MapItemRec
    Num As Byte
    Value As Long
    Dur As Integer
   
    x As Byte
    y As Byte
End Type


Add below that this (remove the old npc rec):
Type DropItemRec
    ItemNum As Byte
    Chance As Integer
    ItemValue As Integer
End Type

Type DropRec
    Name As String
    ItemDrop(1 To MAX_DROP_ITEMS) As DropItemRec
End Type

Type NpcRec
    Name As String * NAME_LENGTH
    AttackSay As String * 255
   
    Sprite As Integer
    SpawnSecs As Long
    Behavior As Byte
    Range As Byte
   
    Drop As Byte
   
    STR  As Byte
    DEF As Byte
    SPEED As Byte
    MAGI As Byte
End Type


Go into your frmIndex coding and find:
    If InSpellEditor = True Then
        Call SendData("EDITSPELL" & SEP_CHAR & EditorIndex & SEP_CHAR & END_CHAR)
    End If


And add below it:
    If InDropEditor = True Then
        Call SendData("EDITDROP" & SEP_CHAR & EditorIndex & SEP_CHAR & END_CHAR)
    End If


Find:
    InSpellEditor = False


And add below it:
    InDropEditor = False


As for the editor make these things:
Form - frmDropEditor
Label1 - lblDroppings
Label2 - lblItemNum
Label3 - lblValue
Label4 - lblItemName
Textbox1 - txtDropName
Textbox2 - txtChance
HScroll1 - scrlItemDrop
HScroll2 - scrlItemNum
HScroll3 - scrlValue
CommandButton1 - cmdOk
CommandButton2 - cmdCancel


Go into the coding and add this:
Private Sub cmdCancel_Click()
    Call DropEditorCancel
End Sub

Private Sub cmdOk_Click()
    Call DropEditorOk
End Sub

Private Sub Form_Load()
    scrlItemDrop.Max = MAX_DROP_ITEMS
    scrlItemNum.Max = MAX_ITEMS
End Sub

Private Sub scrlItemDrop_Change()
    lblDroppings.Caption = scrlItemDrop.Value
   
    scrlItemNum.Value = Drop(EditorIndex).ItemDrop(scrlItemDrop.Value).ItemNum
    txtChance.Text = Drop(EditorIndex).ItemDrop(scrlItemDrop.Value).Chance
    scrlValue.Value = Drop(EditorIndex).ItemDrop(scrlItemDrop.Value).ItemValue
End Sub

Private Sub scrlItemNum_Change()
    lblItemNum.Caption = STR(scrlItemNum.Value)
    lblItemName.Caption = Empty
   
    If scrlItemNum.Value > 0 Then
        lblItemName.Caption = Trim(Item(scrlItemNum.Value).Name)
    End If
   
    Drop(EditorIndex).ItemDrop(scrlItemDrop.Value).ItemNum = scrlItemNum.Value
End Sub

Private Sub scrlValue_Change()
    lblValue.Caption = STR(scrlValue.Value)
   
    Drop(EditorIndex).ItemDrop(scrlItemDrop.Value).ItemValue = scrlValue.Value
End Sub

Private Sub txtChance_Change()
    Drop(EditorIndex).ItemDrop(scrlItemDrop.Value).Chance = Val(txtChance.Text)
End Sub


And now you should be done.. Enjoy!! If there are any bugs please let me know and i'll fix them right away.. Thanks guys

Oh, i've tested this on a blank mse so it should work 100%, i fixed the small saving error.. It was a stupid little error.. Damn those stupid little errors..
http://www.darkechoimages.homestead.com/files/MSE_Dropping_System.rar -

-------------



Replies:
Posted By: Sonire
Date Posted: 16 February 2006 at 7:45am
Seems like it's coming along nicely :)
Can't wait to see the rest. Nice work


-------------
I grant permission for anyone to alter a tutorial previously posted by me for use in a tutorial submission for MSE, so long as "Originally Coded By Sonire" is credited at the top of the tutorial.


Posted By: Misunderstood
Date Posted: 16 February 2006 at 1:39pm
What if you helped them build the drop editor, inside the npc editor ;)
or what if they did it themselves! Hah its just an idea that would make it much easier to edit.


Posted By: Sync
Date Posted: 26 February 2006 at 12:55pm
If you make use of the code tag, then I can approve this, until then, its sorta unreadable.



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