Officer Johnson Posted January 3, 2015 Author Share Posted January 3, 2015 Saw a few people asking for stuff about multiple npc drops like tutorials not working and all so im just taking the code i used in Eclipse Renewal and bringing it to you here in a tutorial hope someone finds it helpful.Lets get to the code:Server:first in **modConstants** under the general constants.add:```Public Const MAX_NPC_DROPS As Byte = 10```now head over to **modTypes** and in **NpcRec**change:```DropChanceDropItemDropItemValue```to:```DropChance(1 to MAX_NPC_DROPS) As DoubleDropItem(1 To MAX_NPC_DROPS) As LongDropItemValue(1 To MAX_NPC_DROPS) As Long```now in **modCombat** in thesub **PlayerAttackNpc** find:```'Drop the goods if they get it```and **Replace**:```n = Int(Rnd * Npc(npcNum).DropChance) + 1If n = 1 ThenCall SpawnItem(Npc(npcNum).DropItem, Npc(npcNum).DropItemValue, mapNum, MapNpc(mapNum).Npc(mapNpcNum).x, MapNpc(mapNum).Npc(mapNpcNum).y)End If```with:``` For n = 1 To MAX_NPC_DROPSIf Npc(NpcNum).DropItem(n) = 0 Then Exit ForIf Rnd <= Npc(NpcNum).DropChance(n) ThenCall SpawnItem(Npc(NpcNum).DropItem(n), Npc(NpcNum).DropItemValue(n), MapNum, MapNpc(MapNum).Npc(mapNpcNum).x, MapNpc(MapNum).Npc(mapNpcNum).y)End IfNext```If you have pets in your game you will need the following:***ONLY ADD IF YOU HAVE PETS AND THE FOLLOWING SUB IN YOUR GAME.** In **modCombat** in **NpcAttackNpc:**find:```' Drop the goods if they get it'For n = 1 to MAX_NPC_DROPS```under it add:```For n = 1 To MAX_NPC_DROPS If Npc(vNpcNum).DropItem(n) = 0 Then Exit For If Rnd <= Npc(vNpcNum).DropChance(n) Then Call SpawnItem(Npc(vNpcNum).DropItem(n), Npc(vNpcNum).DropItemValue(n), MapNum, MapNpc(MapNum).Npc(Victim).x, MapNpc(MapNum).Npc(Victim).y) End If Next```Client Side:in **modConstants** under the **General constants** add:```Public Const MAX_NPC_DROPS As Byte = 10 ```now in **modTypes** in **NpcRec**:change:```DropChanceDropItemDropItemValue ```to:```DropChance(1 to MAX_NPC_DROPS) As DoubleDropItem(1 To MAX_NPC_DROPS) As LongDropItemValue(1 To MAX_NPC_DROPS) As Long```Now in frmEditor_Npc code at the top under Option Explicit add:```Private DropIndex As Byte```Form Work:add a scrlbar to the fraDrop named: **scrlDrop****make the scrlbars max 10 (or number of MAX_NPC_DROPS)**now double click on the scrlBar and make the code the following:```Private Sub scrlDrop_Change()DropIndex = scrlDrop.Value fraDrop.Caption = "Drop - " & DropIndex txtChance.text = NPC(EditorIndex).DropChance(DropIndex) scrlNum.Value = NPC(EditorIndex).DropItem(DropIndex) scrlValue.Value = NPC(EditorIndex).DropItemValue(DropIndex)End Sub```now double click scrlNum change:```Npc(EditorIndex).DropItem = scrlNum.value```to:```NPC(EditorIndex).DropItem(scrlDrop.Value) = scrlNum.Value```now click scrlValuechange:```Npc(EditorIndex).DropItemValue = scrlValue.value```to:```NPC(EditorIndex).DropItemValue(scrlDrop.Value) = scrlValue.Value```click on txtChance and make it the following:```Private Sub txtChance_Change() On Error GoTo chanceErrif Not IsNumeric(txtChance.text) and not Right$(txtChance.text, 1) = "%" and not InStr(1, txtChance.text, "/") > 0 and not InStr(1, txtChance.text, ".") ThentxtChance.text = "0"NPC(EditorIndex).DropChance(scrlDrop.Value) = 0Exit Subend ifif Right$(txtChance.text, 1) = "%" Then txtChance.text = Left(txtChance.text, Len(txtChance.text) - 1) / 100Elseif InStr(1, txtChance.text, "/") > 0 ThenDim i() as stringi = Split(txtChance.text = Int(i(0) / i(1) * 1000 / 1000end ifIf txtChance.text > 1 or txtChance.text < 0 ThenErr.Description = "Value must be between 0 and 1!"GoTo chanceErrEnd ifNPC(EditorIndex).DropChance(scrlDrop.Value) = txtChance.textExit subchanceErr: MsgBox "Invalid entry for chance! " & Err.Description txtChance.text = "0" NPC(EditorIndex).DropChance(scrlDrop.Value) = 0End Sub```that should be it, if any errors let me know :)Credits: Ballie for most of code Link to comment Share on other sites More sharing options...
Guest Posted January 3, 2015 Share Posted January 3, 2015 Might wanna credit Ballie, this looks like code from his original tutorial. Link to comment Share on other sites More sharing options...
Officer Johnson Posted January 3, 2015 Author Share Posted January 3, 2015 it is his :P i just changed few things to right places :P, plus i never said it was mine just i used this code in renewal :) Link to comment Share on other sites More sharing options...
Justin Knight Posted January 4, 2015 Share Posted January 4, 2015 Im not good at vb6 at all but here's a few things I had to do to get this working.In modGameEditors find this```.txtChance.text = CStr(Npc(EditorIndex).DropChance).scrlNum.Value = Npc(EditorIndex).DropItem.scrlValue.Value = Npc(EditorIndex).DropItemValue```and change it to this```.txtChance.text = CStr(Npc(EditorIndex).DropChance(1)).scrlNum.Value = Npc(EditorIndex).DropItem(1).scrlValue.Value = Npc(EditorIndex).DropItemValue(1)```in the last block of code in the OP```i = Split(txtChance.text = Int(i(0) / i(1) * 1000 / 1000```just needs some end parentheses```i = Split(txtChance.text = Int(i(0) / i(1)) * 1000 / 1000)```I also set the scroll bar minimum to 1 that seems to help too.WARNING! I don't know what I'm doing! This could all be wrong!!! Link to comment Share on other sites More sharing options...
Officer Johnson Posted January 4, 2015 Author Share Posted January 4, 2015 > Im not good at vb6 at all but here's a few things I had to do to get this working.> > In modGameEditors find this> > ```> .txtChance.text = CStr(Npc(EditorIndex).DropChance)> .scrlNum.Value = Npc(EditorIndex).DropItem> .scrlValue.Value = Npc(EditorIndex).DropItemValue> ```> and change it to this> ```> .txtChance.text = CStr(Npc(EditorIndex).DropChance(0))> .scrlNum.Value = Npc(EditorIndex).DropItem(0)> .scrlValue.Value = Npc(EditorIndex).DropItemValue(0)> ```> in the last block of code in the OP> ```> i = Split(txtChance.text = Int(i(0) / i(1) * 1000 / 1000> ```> just needs some end parentheses> ```> i = Split(txtChance.text = Int(i(0) / i(1)) * 1000 / 1000)> ```WARNING! I don't know what I'm doing! This could all be wrong!!!Nope it's good simple mistakes I made. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now