Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Npc's Drop Multiple Items
#1
Ok the server side works in MS4 but I had to leave for work so I wasn't able to test out the client side, but I installed it, and it does work in MS3.0.3, and MSEbuild1 so, here's the code. And yes I think someone else did one of these tutorials on the old forums but, I did not see it posted on here.

Server Side
Add this to SendEditNpcTo after the other drop chances
Code:
& SEP_CHAR & Npc(NpcNum).DropChance2 & SEP_CHAR & Npc(NpcNum).DropItem2 & SEP_CHAR & Npc(NpcNum).DropItemValue2 & SEP_CHAR & Npc(NpcNum).DropChance3 & SEP_CHAR & Npc(NpcNum).DropItem3 & SEP_CHAR & Npc(NpcNum).DropItemValue3 & SEP_CHAR & Npc(NpcNum).DropChance4 & SEP_CHAR & Npc(NpcNum).DropItem4 & SEP_CHAR & Npc(NpcNum).DropItemValue4 & SEP_CHAR & Npc(NpcNum).DropChance5 & SEP_CHAR & Npc(NpcNum).DropItem5 & SEP_CHAR & Npc(NpcNum).DropItemValue5
then add this to the npc rec
Code:
DropChance2 As Integer
    DropItem2 As Byte
    DropItemValue2 As Integer
    DropChance3 As Integer
    DropItem3 As Byte
    DropItemValue3 As Integer
    DropChance4 As Integer
    DropItem4 As Byte
    DropItemValue4 As Integer
    DropChance5 As Integer
    DropItem5 As Byte
    DropItemValue5 As Integer
then add to HandleSaveNpc
Code:
Npc(n).DropChance2 = Val(Parse(11))
        Npc(n).DropItem2 = Val(Parse(12))
        Npc(n).DropItemValue2 = Val(Parse(13))
        Npc(n).DropChance3 = Val(Parse(14))
        Npc(n).DropItem3 = Val(Parse(15))
        Npc(n).DropItemValue3 = Val(Parse(16))
        Npc(n).DropChance4 = Val(Parse(17))
        Npc(n).DropItem4 = Val(Parse(18))
        Npc(n).DropItemValue4 = Val(Parse(19))
        Npc(n).DropChance5 = Val(Parse(20))
        Npc(n).DropItem5 = Val(Parse(21))
        Npc(n).DropItemValue5 = Val(Parse(22))
Add this to attacknpc
Code:
' Drop the goods if they get it
n = Int(Rnd * Npc(NpcNum).DropChance2) + 1
If n = 1 Then
Call SpawnItem(Npc(NpcNum).DropItem2, Npc(NpcNum).DropItemValue2, MapNum, MapNpc(MapNum, MapNpcNum).x, MapNpc(MapNum, MapNpcNum).y)
End If
' Drop the goods if they get it
n = Int(Rnd * Npc(NpcNum).DropChance3) + 1
If n = 1 Then
Call SpawnItem(Npc(NpcNum).DropItem3, Npc(NpcNum).DropItemValue3, MapNum, MapNpc(MapNum, MapNpcNum).x, MapNpc(MapNum, MapNpcNum).y)
End If
' Drop the goods if they get it
n = Int(Rnd * Npc(NpcNum).DropChance4) + 1
If n = 1 Then
Call SpawnItem(Npc(NpcNum).DropItem4, Npc(NpcNum).DropItemValue4, MapNum, MapNpc(MapNum, MapNpcNum).x, MapNpc(MapNum, MapNpcNum).y)
End If
' Drop the goods if they get it
n = Int(Rnd * Npc(NpcNum).DropChance5) + 1
If n = 1 Then
Call SpawnItem(Npc(NpcNum).DropItem5, Npc(NpcNum).DropItemValue5, MapNum, MapNpc(MapNum, MapNpcNum).x, MapNpc(MapNum, MapNpcNum).y)
End If
Thats all server side
Now to the Client Side

Add this to handleupdatenpc
Code:
Npc(n).DropChance2 = 0
        Npc(n).DropItem2 = 0
        Npc(n).DropItemValue2 = 0
        Npc(n).DropChance3 = 0
        Npc(n).DropItem3 = 0
        Npc(n).DropItemValue3 = 0
        Npc(n).DropChance4 = 0
        Npc(n).DropItem4 = 0
        Npc(n).DropItemValue4 = 0
        Npc(n).DropChance5 = 0
        Npc(n).DropItem5 = 0
        Npc(n).DropItemValue5 = 0
Then add this to handleeditnpc
Code:
Npc(n).DropChance2 = Val(Parse(11))
        Npc(n).DropItem2 = Val(Parse(12))
        Npc(n).DropItemValue2 = Val(Parse(13))
        Npc(n).DropChance3 = Val(Parse(14))
        Npc(n).DropItem3 = Val(Parse(15))
        Npc(n).DropItemValue3 = Val(Parse(16))
        Npc(n).DropChance4 = Val(Parse(17))
        Npc(n).DropItem4 = Val(Parse(18))
        Npc(n).DropItemValue4 = Val(Parse(19))
        Npc(n).DropChance5 = Val(Parse(20))
        Npc(n).DropItem5 = Val(Parse(21))
        Npc(n).DropItemValue5 = Val(Parse(22))
Add this to sendsavenpc
Code:
& SEP_CHAR & Npc(NpcNum).DropChance2 & SEP_CHAR & Npc(NpcNum).DropItem2 & SEP_CHAR & Npc(NpcNum).DropItemValue2 & SEP_CHAR & Npc(NpcNum).DropChance3 & SEP_CHAR & Npc(NpcNum).DropItem3 & SEP_CHAR & Npc(NpcNum).DropItemValue3 & SEP_CHAR & Npc(NpcNum).DropChance4 & SEP_CHAR & Npc(NpcNum).DropItem4 & SEP_CHAR & Npc(NpcNum).DropItemValue4 & SEP_CHAR & Npc(NpcNum).DropChance5 & SEP_CHAR & Npc(NpcNum).DropItem5 & SEP_CHAR & Npc(NpcNum).DropItemValue5
Add this to NpcRec
Code:
DropChance2 As Integer
    DropItem2 As Byte
    DropItemValue2 As Integer
    DropChance3 As Integer
    DropItem3 As Byte
    DropItemValue3 As Integer
    DropChance4 As Integer
    DropItem4 As Byte
    DropItemValue4 As Integer
    DropChance5 As Integer
    DropItem5 As Byte
    DropItemValue5 As Integer
Add this to Npceditorinit
Code:
frmNpcEditor.txtChance2.Text = Str(Npc(EditorIndex).DropChance2)
    frmNpcEditor.scrlNum2.Value = Npc(EditorIndex).DropItem2
    frmNpcEditor.scrlValue2.Value = Npc(EditorIndex).DropItemValue2
    frmNpcEditor.txtChance3.Text = Str(Npc(EditorIndex).DropChance3)
    frmNpcEditor.scrlNum3.Value = Npc(EditorIndex).DropItem3
    frmNpcEditor.scrlValue3.Value = Npc(EditorIndex).DropItemValue3
    frmNpcEditor.txtChance4.Text = Str(Npc(EditorIndex).DropChance4)
    frmNpcEditor.scrlNum4.Value = Npc(EditorIndex).DropItem4
    frmNpcEditor.scrlValue4.Value = Npc(EditorIndex).DropItemValue4
    frmNpcEditor.txtChance5.Text = Str(Npc(EditorIndex).DropChance5)
    frmNpcEditor.scrlNum5.Value = Npc(EditorIndex).DropItem5
    frmNpcEditor.scrlValue5.Value = Npc(EditorIndex).DropItemValue5
Add this to npceditorok
Code:
Npc(EditorIndex).DropChance2 = Val(frmNpcEditor.txtChance2.Text)
    Npc(EditorIndex).DropItem2 = frmNpcEditor.scrlNum2.Value
    Npc(EditorIndex).DropItemValue2 = frmNpcEditor.scrlValue2.Value
    Npc(EditorIndex).DropChance3 = Val(frmNpcEditor.txtChance3.Text)
    Npc(EditorIndex).DropItem3 = frmNpcEditor.scrlNum3.Value
    Npc(EditorIndex).DropItemValue3 = frmNpcEditor.scrlValue3.Value
    Npc(EditorIndex).DropChance4 = Val(frmNpcEditor.txtChance4.Text)
    Npc(EditorIndex).DropItem4 = frmNpcEditor.scrlNum4.Value
    Npc(EditorIndex).DropItemValue4 = frmNpcEditor.scrlValue4.Value
    Npc(EditorIndex).DropChance5 = Val(frmNpcEditor.txtChance5.Text)
    Npc(EditorIndex).DropItem5 = frmNpcEditor.scrlNum5.Value
    Npc(EditorIndex).DropItemValue5 = frmNpcEditor.scrlValue5.Value
Then make duplicates of each of the drop things in the npceditor.
Now this makes it so that if any of the items that are on the same chance # like item 1 & 2 are set to chance 1 out of 2 and then 3, 4, 5 are set to a diffrent number it will drop the 2 at the number it gets first, so some updating might need to be done to it a little later on.
hope this works if not let me know and I'll try to figure it out.
To make this work for MSE and 3.0.3 just copy and change the save and load code in save and loadnpc.
Reply
#2
You should do this with an array. It'd be much more optimized.
Reply
#3
I am not sure how to work with arrays but I am going to convert it to use with's when I get home to speed it up a little.
Reply
#4
Just learn to use an array.

DropItem(1 to 3) as byte

(I think..)
Reply
#5
I googled it and here's what I came up with is that what your thinking of?
http://visualbasic.freetutes.com/learn-vb6/lesson6.html
Reply
#6
DarkX Wrote:I googled it and here's what I came up with is that what your thinking of?
http://visualbasic.freetutes.com/learn-vb6/lesson6.html

Obviously.
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
#7
I'll get to working on it tonight, and try to convert to arrays
Reply
#8
Did this ever get update to arrays and is it still usable with the new ms4
Reply
#9
This is all serverside, but it looks like it should still work with MS4. All it does is create a bunch of new values in the NPC file, so if you use this you'll either have to put something in to add in those blank values, or delete all your NPC files. You'll also have to do clientside, which shouldn't be too hard. It would mainly just be adding in a bunch of scrollbars, etc, to the NPC editor, then having the values sent to the server when you save then NPC.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)