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

[EO2.0] Simple 'OnDeath' Random Equipment Drops


Justn
 Share

Recommended Posts

I thought this was pretty cool and I'm using a modified version of this for my project. If a player is killed he has a 25 out of 100 chance (kinda) he will drop a piece of his equipment.This is a simple code and can easily be modified for a variety of things including penalty for pks and dropping multiple items instead of just one. **Increase** the 'Rate' to **decrease** **the chance** and **decrease** the 'Rate' to **increase the chance**. All credits go to Richy for this piece of code. Everything is in Sub OnDeath in modplayer server-side.

**Server**

**modPlayer:**

**Find:**
```
Sub OnDeath(ByVal Index As Long)
```
**Under it add:**
```
Dim Rate As Long
    Dim DropNum As Long
```
**Next find:**
```
' Drop all worn items
    For i = 1 To Equipment.Equipment_Count - 1
        If GetPlayerEquipment(Index, i) > 0 Then
            PlayerMapDropItem Index, GetPlayerEquipment(Index, i), 0
        End If
    Next
```
**And Replace it with this:**
```
Rate = 75

If Rand(1, 100) >= Rate Then

        DropNum = Rand(1, 4)

Select Case DropNum

Case 1
If GetPlayerEquipment(index, Weapon) > 0 Then
            PlayerMapDropItem index, GetPlayerEquipment(index, Weapon), 0
        End If
GiveInvItem index, GetPlayerEquipment(index, Weapon), 0
        SetPlayerEquipment index, 0, Weapon
Case 2
If GetPlayerEquipment(index, Helmet) > 0 Then
            PlayerMapDropItem index, GetPlayerEquipment(index, Helmet), 0
        End If
GiveInvItem index, GetPlayerEquipment(index, Helmet), 0
        SetPlayerEquipment index, 0, Helmet
Case 3
If GetPlayerEquipment(index, Armor) > 0 Then
            PlayerMapDropItem index, GetPlayerEquipment(index, Armor), 0
        End If
GiveInvItem index, GetPlayerEquipment(index, Armor), 0
        SetPlayerEquipment index, 0, Armor
Case 4
If GetPlayerEquipment(index, Shield) > 0 Then
            PlayerMapDropItem index, GetPlayerEquipment(index, Shield), 0
        End If
GiveInvItem index, GetPlayerEquipment(index, Shield), 0
        SetPlayerEquipment index, 0, Shield
End Select
End If

Rate = 90
If Rand(1, 100) >= Rate Then
For i = 1 To MAX_INV
If Item(i).Type <> ITEM_TYPE_CURRENCY Then
    PlayerMapDropItem index, i, GetPlayerInvItemValue(index, i)
    End If
Next
End If
```
That's all its pretty simple. The random is pretty random so its not really 25 out of 100 every time. Would be nice to make it a % chance instead =p
Link to comment
Share on other sites

  • 3 months later...

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