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

Ya, its not working that way for me… Its only letting me set them as 0 or 1 and if I do anything thats like 2.0 or something it changes it to 0.... So its either an item drops 100% of the time or 0% of the time....

the code for entering shit into txtChange is this...
```
Private Sub txtChance_Change()
    On Error GoTo chanceErr
    Dim DropIndex As Long

    If Not IsNumeric(txtChance.text) And Not Right$(txtChance.text, 1) = "%" And Not InStr(1, txtChance.text, "/") > 0 And Not InStr(1, txtChance.text, ".") Then
        txtChance.text = "0"
        Npc(EditorIndex).DropChance(DropIndex) = 0
        Exit Sub
    End If

    If Right$(txtChance.text, 1) = "%" Then
        txtChance.text = left(txtChance.text, Len(txtChance.text) - 1) / 100
    ElseIf InStr(1, txtChance.text, "/") > 0 Then
        Dim i() As String
        i = Split(txtChance.text, "/")
        txtChance.text = Int(i(0) / i(1) * 1000) / 1000
    End If

    If txtChance.text > 1 Or txtChance.text < 0 Then
        Err.Description = "Value must be between 0 and 1!"
        GoTo chanceErr
    End If

    Npc(EditorIndex).DropChance(DropIndex) = txtChance.text
    Exit Sub

chanceErr:
    MsgBox "Invalid entry for chance! " & Err.Description
    txtChance.text = "0"
    Npc(EditorIndex).DropChance(DropIndex) = 0
End Sub
```
Thats what it is in the attached frm_Editor_NPC and that only lets it be 0 or 1…
Link to comment
Share on other sites

  • Replies 109
  • Created
  • Last Reply

Top Posters In This Topic

@Ertzel:

> Ya, its not working that way for me… Its only letting me set them as 0 or 1 and if I do anything thats like 2.0 or something it changes it to 0.... So its either an item drops 100% of the time or 0% of the time....
>
> the code for entering shit into txtChange is this...
> ```
> Private Sub txtChance_Change()
>     On Error GoTo chanceErr
>     Dim DropIndex As Long
>    
>     If Not IsNumeric(txtChance.text) And Not Right$(txtChance.text, 1) = "%" And Not InStr(1, txtChance.text, "/") > 0 And Not InStr(1, txtChance.text, ".") Then
>         txtChance.text = "0"
>         Npc(EditorIndex).DropChance(DropIndex) = 0
>         Exit Sub
>     End If
>    
>     If Right$(txtChance.text, 1) = "%" Then
>         txtChance.text = left(txtChance.text, Len(txtChance.text) - 1) / 100
>     ElseIf InStr(1, txtChance.text, "/") > 0 Then
>         Dim I() As String
>         I = Split(txtChance.text, "/")
>         txtChance.text = Int(I(0) / I(1) * 1000) / 1000
>     End If
>    
>     If txtChance.text > 1 Or txtChance.text < 0 Then
>         Err.Description = "Value must be between 0 and 1!"
>         GoTo chanceErr
>     End If
>    
>     Npc(EditorIndex).DropChance(DropIndex) = txtChance.text
>     Exit Sub
>    
> chanceErr:
>     MsgBox "Invalid entry for chance! " & Err.Description
>     txtChance.text = "0"
>     Npc(EditorIndex).DropChance(DropIndex) = 0
> End Sub
> ```
> Thats what it is in the attached frm_Editor_NPC and that only lets it be 0 or 1…

No, you don't understand, you cannot go above or bellow 0 & 1 everything between 0 & 1 you can pick, Example: 0.001, 0.00002499429, 0.12894718742047990127490, 0.5 = 1/2…
Link to comment
Share on other sites

  • 2 months later...
redo this 4 times. I make it works! Great! Thanks a lot.
However, I got a little problem that in my chance value in editor, there will be a huge number in it… Everytime I want to change the chance, I have to delete it, then type in.
Just like pic in my attachment....

Thank you very much!
Link to comment
Share on other sites

Er, I think I might be a bit of a moron then… This is the code I'm trying to replace, right?
```
        ' Drop the goods if they get it
        n = Int(Rnd * Npc(vNpcNum).DropChance) + 1
        If n = 1 Then
            Call SpawnItem(Npc(vNpcNum).DropItem, Npc(vNpcNum).DropItemValue, MapNum, MapNpc(MapNum).Npc(Victim).x, MapNpc(MapNum).Npc(Victim).y)
        End If
```If so, it isn't present anywhere in any server module. If not… Well, then I'm probably just too thick to get this to work.
Link to comment
Share on other sites

It's still here, things just changed locations and some minor tweaks to the remarks.. But all the code is still there if you know where to look. :) And you can't blatantly copy/paste shit anymore, as the editors have changed as well.. Which is good :P

EDIT : This actually requires more work to get it functional with the new Beta then I had anticipated.. It's worth the effort though. :)
Link to comment
Share on other sites

Er, I don't think there's a way to re-download EO 1.5 now that the new beta's out. It's definitely not there. I must have gotten rid of it by accident, and I don't know enough yet to get this working in 2.0, but thank you for your help.
–-------
EDIT: Nevermind, found a way to get the older version. Thanks again for your help.
Link to comment
Share on other sites

  • 4 weeks later...
  • 4 weeks later...
  • 2 weeks later...
For the people that having trouble with 'Drop the goods if they get it part, try this code (works for me) :
```
'Drop the goods if they get it
                For y = 1 To MAX_NPC_DROPS
                    If NPC(npcNum).DropItem(y) = 0 Then Exit For
                    If Rnd <= NPC(npcNum).DropChance(y) Then
                        Call SpawnItem(NPC(npcNum).DropItem(y), NPC(npcNum).DropItemValue(y), mapNum, MapNpc(mapNum).NPC(mapNpcNum).x, MapNpc(mapNum).NPC(mapNpcNum).y)
                    End If
                Next
```
Link to comment
Share on other sites

  • 2 weeks later...
I clicked on start with full compile, but I got an error and it said:

Compile Error: Method of data member not found

And pointed to this line, highlighting the ".sound" part:

```
soundName = Trim$(Npc(entityNum).Sound)
```
Any fixes?
Link to comment
Share on other sites

@NexCarcer:

> I clicked on start with full compile, but I got an error and it said:
>
> Compile Error: Method of data member not found
>
> And pointed to this line, highlighting the ".sound" part:
>
> ```
> soundName = Trim$(Npc(entityNum).Sound)
> ```
> Any fixes?

Load up your server-side code and then go to modTypes. Does your NpcRec look like this?

```
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 10) As Double
    DropItem(1 To 10) As Long
    DropItemValue(1 To 10) As Long
    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
```
You may have the "Sound As String *NAME_LENGTH" missing.
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...