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

[EO] Multiple Item Drops and Percentile Chances


balliztik1
 Share

Recommended Posts

There were two things that bugged me about NPC item drops in Eclipse Origins. The first was the lack of multiple drops. That had been done in past Eclipse releases and seemed almost necessary to add in. The second has been present for as long as I can remember. I hate the "1 in X" drop chance, particularly because of its inaccuracy. It quickly jumps from 100% chance to 50% chance to 33.3% chance, with no option of between-values. I decided to rectify these two issues I had with a little bit of editing.

_This will require deleting all your NPCs unless you code a converter_

**Client-Side**
In modTypes, change the NpcRec to this:

```
Private Type NpcRec
    Name As String * NAME_LENGTH
    AttackSay As String * 100
    Sprite As Integer
    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
    faction As Byte
    HP As Long
    EXP As Long
    Animation As Long
End Type
```
Make sure to add this to modConstants as well:
```
Public Const MAX_NPC_DROPS As Byte = 10
```

Next, you'll need to download the attached form files and replace your old ones. If you've changed anything, you can just copy the new controls and code from that file.

**Server-side**

On the server-side, there's a few more changes. Firstly, do the same steps as above for modTypes and modConstants. Next, we change the logic statements. Find this line in modGameLogic:

```
        ' Drop the goods if they get it
```
Make the code underneath that look like so:

```
        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
```
You'll also find the same line in modPlayer:

```
        ' Drop the goods if they get it
```
Replace that code bit with this:

```
        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
```

And that's all! This adds a couple new features to the NPC editor to comply with the changes.

* The "Chance" box now accepts only a decimal value from 0 to 1\. You can enter fractional values as well, now. For instance, you can type "5/12" for a 5 of 12 chance, or "1/10" for a 1 of 10 chance. The number will auto-convert to decimal. Additionally, you can now use percentages. Entering "25%" for example will automatically convert to ".25".
* There is now a scrollbar that determines which item drop to edit. The default maximum, as shown in the code above, is 10, but can be altered as you see fit. Marking any item number as 0 will cause the loop to exit when the NPC drop logic fires, so you cannot leave drops 1 and 2 blank and start with item drop 3, for example.

Here's a little screenshot for those interested:

![](http://beaubuckley.info/derrick/DropChanges.png)
Link to comment
Share on other sites

  • Replies 109
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...
That sucks XD I'm completely horrible at scripting, I can't read any of it, and I can't source edit at all. I don't even have VB6 or whatever you use for it.

Edit: Replacing those files doesn't change anything at all if you don't do all the work above. I wish he would put the edited files as attachments, but if I ask, I'd feel like a total ass.
Link to comment
Share on other sites

Edited files or not, if you don't have VB6, this isn't going to be compilable. Plus, since this is a third party edit, and a new Origins release is potentially coming out soon, compiling these edits into new executables would only benefit people for a couple days. Then, they'd be left with non-transferable items for the new version.
Link to comment
Share on other sites

  • 3 weeks later...
Ok, I tried commenting out the dropChance line and running the compile, and then it gives me an the Type Missmatch error in these two parts also..
```
Private Type NpcRec
    DropItem(1 To MAX_NPC_DROPS) As Byte
    DropItemValue(1 To MAX_NPC_DROPS) As Integer
End Type
```
Link to comment
Share on other sites

@Ertzel:

> whenever I try to compile the client, I get this error
> in modGameEditors, under Public Sub NpcEditorInit()
> ```
>         .txtChance.text = CStr(Npc(EditorIndex).DropChance)
> ```

I'm having this exact problem. ;_;
Link to comment
Share on other sites

I went through, had to highlight + right click the .DropChance and click definition. And change it's type. Even though it'll give you the same error for .DropChance and all the .*etc* below it in the sub. So you have to change all their types. :[

If this doesn't work, download the files, open them in a new project, and edit your code accordingly.
Link to comment
Share on other sites

@Rose:

> I went through, had to highlight + right click the .DropChance and click definition. And change it's type. Even though it'll give you the same error for .DropChance and all the .*etc* below it in the sub. So you have to change all their types. :[
>
> If this doesn't work, download the files, open them in a new project, and edit your code accordingly.

what she said..
Link to comment
Share on other sites

@Ertzel:

> whenever I try to compile the client, I get this error
> in modGameEditors, under Public Sub NpcEditorInit()
> ```
>         .txtChance.text = CStr(Npc(EditorIndex).DropChance)
> ```

In NpcEditorInit()

Underneath "**Dim i As Long**" Add:
```
Dim DropIndex As Long
```
Underneath "**EditorIndex = frmEditor_NPC.lstIndex.ListIndex + 1**" Add:
```
DropIndex = frmEditor_NPC.scrlDrop.Value
```
Then replace:
```
.txtChance.text = CStr(Npc(EditorIndex).DropChance)
        .scrlNum.Value = Npc(EditorIndex).DropItem
        .scrlValue.Value = Npc(EditorIndex).DropItemValue
```
With:

```
.txtChance.text = CStr(Npc(EditorIndex).DropChance(DropIndex))
        .scrlNum.Value = Npc(EditorIndex).DropItem(DropIndex)
        .scrlValue.Value = Npc(EditorIndex).DropItemValue(DropIndex)
```
Go into the frmEditor_NPC and search for "Private Sub scrlNum_Change()"
Underneath it Add:
```
DropIndex = scrlDrop.Value
```And do the same for "Private Sub scrlValue_Change()"

This should fix the Mismatch error, as well as the Subscript out of range error you would receive from adding the DropIndex.
Link to comment
Share on other sites

@DJMaxus:

> @Ertzel:
>
> > whenever I try to compile the client, I get this error
> > in modGameEditors, under Public Sub NpcEditorInit()
> > ```
> >         .txtChance.text = CStr(Npc(EditorIndex).DropChance)
> > ```
>
> In NpcEditorInit()
>
> Underneath "**Dim I As Long**" Add:
> ```
> Dim DropIndex As Long
> ```
> Underneath "**EditorIndex = frmEditor_NPC.lstIndex.ListIndex + 1**" Add:
> ```
> DropIndex = frmEditor_NPC.scrlDrop.Value
> ```
> Then replace:
> ```
> .txtChance.text = CStr(Npc(EditorIndex).DropChance)
>         .scrlNum.Value = Npc(EditorIndex).DropItem
>         .scrlValue.Value = Npc(EditorIndex).DropItemValue
> ```
> With:
>
> ```
> .txtChance.text = CStr(Npc(EditorIndex).DropChance(DropIndex))
>         .scrlNum.Value = Npc(EditorIndex).DropItem(DropIndex)
>         .scrlValue.Value = Npc(EditorIndex).DropItemValue(DropIndex)
> ```
> Go into the frmEditor_NPC and search for "Private Sub scrlNum_Change()"
> Underneath it Add:
> ```
> DropIndex = scrlDrop.Value
> ```And do the same for "Private Sub scrlValue_Change()"
>
> This should fix the Mismatch error, as well as the Subscript out of range error you would receive from adding the DropIndex.

Doesn´t work, it gives an error at:

```
DropIndex = frmEditor_NPC[b].scrlDrop[/b].Value
```(At .scrlDrop)
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...