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

Drop Items on Death (Efficient)


Link
 Share

Recommended Posts

So there are some people who are wondering how to get items dropped on death, but they'd like the more valuable items not to be dropped. Small tutorial here showing just how that's done. This tutorial makes it so that every item is dropped on death besides the two items that are the most valuable in your inventory. Also basically if you kill another player or they're killed you can steal their items.

Feel free to make additions or notify me of bugs.

This will all be server sided, so go to **modPlayer** and ctrl + F(quick search) **Sub OnDeath(ByVal index As Long)** below where it says **Call SetPlayerVital(index, Vitals.HP, 0)**

If you still have this code :

```

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

**You can replace it with the following code:**

```

'Brigz's EDIT
Dim ValuedItem(1 To 3) As Byte
Dim Value As Long
For i = 1 To MAX_INV
If GetPlayerInvItemNum(index, i) > 0 Then
If Item(GetPlayerInvItemNum(index, i)).price > 0 Then
If Item(GetPlayerInvItemNum(index, i)).price >= Value Then
ValuedItem(3) = ValuedItem(2)
ValuedItem(2) = ValuedItem(1)
ValuedItem(1) = i

Value = Item(GetPlayerInvItemNum(index, i)).price
End If
End If
End If
Next i

'Drop inventory items
For i = 1 To MAX_INV
If i <> ValuedItem(1) And i <> ValuedItem(2) And i <> ValuedItem(3) Then
PlayerMapDropItem index, i, GetPlayerInvItemValue(index, i)
End If
Next

'Send all equiped items to the inventory to be dumped.
For i = 1 To Equipment.Equipment_Count - 1
If GetPlayerEquipment(index, i) > 0 Then
PlayerMapDropItem index, GetPlayerEquipment(index, i), 0
End If

'Send Weapon
GiveInvItem index, GetPlayerEquipment(index, Weapon), 0
SetPlayerEquipment index, 0, Weapon
'Send Armor
GiveInvItem index, GetPlayerEquipment(index, Armor), 0
SetPlayerEquipment index, 0, Armor
'Send Shield
GiveInvItem index, GetPlayerEquipment(index, Shield), 0
SetPlayerEquipment index, 0, Shield
'Send Helmet
GiveInvItem index, GetPlayerEquipment(index, Helmet), 0
SetPlayerEquipment index, 0, Helmet

Next

'Drop *equipped* inventory items
For i = 1 To MAX_INV
If Not i = ValuedItem(1) And i <> ValuedItem(2) And i <> ValuedItem(3) Then PlayerMapDropItem index, i, 0
Next
```
That's it
**=========================================== Other Wise===============================================================**

Now on the other hand, you may have a code that looks like this:

```

'Drop inventory items, Will make this only apply to player killers.
If GetPlayerPK(index) = YES Then
For i = 1 To MAX_INV
PlayerMapDropItem index, i, GetPlayerInvItemValue(index, i)
Next
'Send all equiped items to the inventory to be dumped.
For i = 1 To Equipment.Equipment_Count - 1
If GetPlayerEquipment(index, i) > 0 Then
PlayerMapDropItem index, GetPlayerEquipment(index, i), 0
End If

'Send Weapon
GiveInvItem index, GetPlayerEquipment(index, Weapon), 0
SetPlayerEquipment index, 0, Weapon
'Send Armor
GiveInvItem index, GetPlayerEquipment(index, Armor), 0
SetPlayerEquipment index, 0, Armor
'Send Shield
GiveInvItem index, GetPlayerEquipment(index, Shield), 0
SetPlayerEquipment index, 0, Shield
'Send Helmet
GiveInvItem index, GetPlayerEquipment(index, Helmet), 0
SetPlayerEquipment index, 0, Helmet

Next
'Drop *equipped* inventory items
For i = 1 To MAX_INV
PlayerMapDropItem index, i, 0
Next
End If
```

If you have a code like this you can replace it with the same thing I posted before which, again, is this:

```

'Brigz's EDIT
Dim ValuedItem(1 To 3) As Byte
Dim Value As Long
For i = 1 To MAX_INV
If GetPlayerInvItemNum(index, i) > 0 Then
If Item(GetPlayerInvItemNum(index, i)).price > 0 Then
If Item(GetPlayerInvItemNum(index, i)).price >= Value Then
ValuedItem(3) = ValuedItem(2)
ValuedItem(2) = ValuedItem(1)
ValuedItem(1) = i

Value = Item(GetPlayerInvItemNum(index, i)).price
End If
End If
End If
Next i

'Drop inventory items
For i = 1 To MAX_INV
If i <> ValuedItem(1) And i <> ValuedItem(2) And i <> ValuedItem(3) Then
PlayerMapDropItem index, i, GetPlayerInvItemValue(index, i)
End If
Next

'Send all equiped items to the inventory to be dumped.
For i = 1 To Equipment.Equipment_Count - 1
If GetPlayerEquipment(index, i) > 0 Then
PlayerMapDropItem index, GetPlayerEquipment(index, i), 0
End If

'Send Weapon
GiveInvItem index, GetPlayerEquipment(index, Weapon), 0
SetPlayerEquipment index, 0, Weapon
'Send Armor
GiveInvItem index, GetPlayerEquipment(index, Armor), 0
SetPlayerEquipment index, 0, Armor
'Send Shield
GiveInvItem index, GetPlayerEquipment(index, Shield), 0
SetPlayerEquipment index, 0, Shield
'Send Helmet
GiveInvItem index, GetPlayerEquipment(index, Helmet), 0
SetPlayerEquipment index, 0, Helmet

Next

'Drop *equipped* inventory items
For i = 1 To MAX_INV
If Not i = ValuedItem(1) And i <> ValuedItem(2) And i <> ValuedItem(3) Then PlayerMapDropItem index, i, 0
Next
```
That's the end:

Thanks to Carim for helping me get a better understanding of how to get the items to be looped through correctly etc. Thanks to Thomas for a base.
Link to comment
Share on other sites

You could also add check if map morale is like arena or none so if arena then items are dropped and other players can get better gear from idiots who dont know how to play ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png) and in none moral map this is disabled so wont ruin happines of leveling. xD
Link to comment
Share on other sites

Thats why u got source code, make arena and arena1, arena is for players who dont care if they loose items or dont but there must be some bonus things like killer gets +20exp for every dropped item, and arena1 where all items are safe in bag. ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png)
Link to comment
Share on other sites

> You could also add check if map morale is like arena or none so if arena then items are dropped and other players can get better gear from idiots who dont know how to play ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png) and in none moral map this is disabled so wont ruin happines of leveling. xD

Domino, good suggestion. In any case how this system is used is really up to the owner of the game who is putting it in, but when I get time I'd be happy to add a check.
Link to comment
Share on other sites

> I'll update the tutorial and add that in when I can, thanks. Right now working on stuff for EVB development.

Make it how you want it. I was only offering a suggestion ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
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...