Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO 2.0][Fixed] Multiple Item Drops and Percentile Chances


Scott
 Share

Recommended Posts

100% Credit goes to Ballie I just fixed it, I take no credit for this code.
Orignal:[http://www.touchofdeathforums.com/smf/index.php/topic,61133.0.html](http://www.touchofdeathforums.com/smf/index.php/topic,61133.0.html)
If you have done any part of the old tutorial start over fresh.

Did it for my own project, figured I'd post it to save people some time.
**Make sure you put both files from the zip in the client/src folder.

Delete the old NPC data files!**

In modType in both **CLIENT/SERVER** replace NpcRec with this one

```
Private Type NpcRec
    Name As String * NAME_LENGTH
    AttackSay As String * 100
    Sound As String * NAME_LENGTH

    Sprite As Long
    SpawnSecs As Long
    Behaviour As Byte
    Range As Byte
    DropChance(1 To MAX_NPC_DROPS) As Double
    DropItem(1 To MAX_NPC_DROPS) As Byte
    DropItemValue(1 To MAX_NPC_DROPS) As Integer
    Stat(1 To Stats.Stat_Count - 1) As Byte
    HP As Long
    EXP As Long
    Animation As Long
    Damage As Long
    Level As Long
End Type

```
In modConstants in both **CLIENT/SERVER** search

```
' General constants
```
Place this under that

```
Public Const MAX_NPC_DROPS As Byte = 10
```

**SERVER**
Search in modCombat for

```
'Drop the goods if they get it
```
Delete

```
n = Int(Rnd * Npc(npcNum).DropChance) + 1

If n = 1 Then
Call SpawnItem(Npc(npcNum).DropItem, Npc(npcNum).DropItemValue, mapNum, MapNpc(mapNum).Npc(mapNpcNum).x, MapNpc(mapNum).Npc(mapNpcNum).y)
End If
```

and replace it with

```
For n = 1 To MAX_NPC_DROPS
If Npc(NpcNum).DropItem(n) = 0 Then Exit For

If Rnd <= Npc(NpcNum).DropChance(n) Then
Call SpawnItem(Npc(NpcNum).DropItem(n), Npc(NpcNum).DropItemValue(n), MapNum, MapNpc(MapNum).Npc(mapNpcNum).x, MapNpc(MapNum).Npc(mapNpcNum).y)
End If
Next

```

**CLIENT**
Search modGameEditors for
```
.txtChance.text = CStr(Npc(EditorIndex).DropChance)
```
Delete

```
.txtChance.text = CStr(Npc(EditorIndex).DropChance)
.scrlNum.Value = Npc(EditorIndex).DropItem
.scrlValue.Value = Npc(EditorIndex).DropItemValue
```
Replace with

```
        .txtChance.text = CStr(Npc(EditorIndex).DropChance(1))
        .scrlNum.Value = Npc(EditorIndex).DropItem(1)
        .scrlValue.Value = Npc(EditorIndex).DropItemValue(1)
```
**The format for drop chance is .percent    Example: .25 = 25%  .16 = 16%  1 = 100%  More than 1 = 100%**

Pretty simple fix, I did not test it after I made it so let me know if there is any errors, forms are attached.
Link to comment
Share on other sites

  • Replies 139
  • Created
  • Last Reply

Top Posters In This Topic

@Justn:

> Can you tell me what you fixed? I used Ballie's tutorial awhile back and it seems to be working fine. Is there a bug or something?

Seemed to be from an older version
1.NpcRec was missing the sound field
2.Some variables where different in the drop loop, it also told you to put it in 2 place, there is only 1 now.
3.Where it starts up the npc editor it was not treating DropChance, DropItem, DropItemValue as arrays which caused an error.
Link to comment
Share on other sites

@Vus:

> It says Compile error: Cant assign to array and marks: .DropItem =

I just installed this on a fresh copy of EO 2.0 works fine, you did something wrong.  Seems like you skipped the last step or did not replace the form. Make sure you put both files from the zip in the client/src folder.
Link to comment
Share on other sites

i solved this problem, but now, i have another one ^^
because i have alatars quest system, i can not copy file you attached cuz it woudl not work, so i copied that fra drop (with codes) and now it gives this error:
In scrlDrop_Change()
**DropItem =** and says variable not defined
Link to comment
Share on other sites

@Vus:

> i solved this problem, but now, i have another one ^^
> because i have alatars quest system, i can not copy file you attached cuz it woudl not work, so i copied that fra drop (with codes) and now it gives this error:
> In scrlDrop_Change()
> **DropItem =** and says variable not defined

You need to declare DropIndex

At the very top of frmEditor_NPC under 

```
Option Explicit
```
Add

```
Private DropIndex As Byte
```

@Ansonla:

> is there another way or tutorial to not replace the forms?

Yes, very easy to do
No tutorial though
Link to comment
Share on other sites

thank you very much :)
now, i sucesfully compiled it and it seems to work ~~, but i cant attack NPC's, not even with spells.~~

Edit: Fixed.

Edit2: Drops wont save for me, i set it up, click save, but when i kill the npc it drops nothing and when i go to npc editor, settings for drops are blank :(
Link to comment
Share on other sites

@Vus:

> thank you very much :)
> now, i sucesfully compiled it and it seems to work ~~, but i cant attack NPC's, not even with spells.~~
>
> Edit: Fixed.
>
> Edit2: Drops wont save for me, i set it up, click save, but when i kill the npc it drops nothing and when i go to npc editor, settings for drops are blank :(

Pm me your source before you put this tutorial in I'll add it for you, other than that pretty hard to fix a problem with out seeing the code.
Link to comment
Share on other sites

I added this to EO 2.0 and ive noticed that the it doesnt matter what the chance is set at, the items ALWAYS drop… also in the npc editor the 1st drop is saving , but not the second or third.. they reset when you exit out and go back into the editor. Im not sure if ive done something wrong or what.
Link to comment
Share on other sites

@Murdock:

> I added this to EO 2.0 and ive noticed that the it doesnt matter what the chance is set at, the items ALWAYS drop… also in the npc editor the 1st drop is saving , but not the second or third.. they reset when you exit out and go back into the editor. Im not sure if ive done something wrong or what.

I can't confirm the always drop thing, but I've set an item at item slot 2 and it saved from the npc.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...