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

Equipment Rare Dropper


Richy420Rich
 Share

Recommended Posts

Something quick I typed up tonight and figured I'd share it to those who wish to have it. Basically the way it is now, it'll scan through your item editor looking for all equipment for a player which is 5 levels higher then them via your items level requirement, it will also scan for that players class, and then it'll randomly select which equipment type to drop.

Alright, I placed this code in modPlayer on server

```
Public Sub RareItem(Byval Index As Long, Byval PlayerLevel As Byte, Byval Class As Byte, Byval MapNum As Long, ByVal NPCx As Long, Byval NPCy As Long)
Dim I As Long
Dim EquipType As Long
Dim Rarity As Long
Dim WeaponNum As Long
Dim HelmetNum As Long
Dim ArmorNum As Long
Dim ShieldNum As Long
Dim DropNum As Long

'Change this to a value you wish.
Rarity = 69

'Add a > or < before the = if you want a better success rate drop.
If Rand(1, 100) = Rarity Then

'Scanning item editor database
For I = 1 To MAX_ITEMS

'Must meet these requirements to continue on
If Len(Trim(Item(I).Name)) > 0 Then
If (PlayerLevel + 5) = Item(I).LevelReq And Class = Item(I).ClassReq Then
If Item(I).Type = ITEM_TYPE_WEAPON Or Item(I).Type = ITEM_TYPE_HELMET Or Item(I).Type = ITEM_TYPE_ARMOR Or Item(I).Type = ITEM_TYPE_SHIELD Then

'It'll find the item numbers for each equip type item available and record them in variables.
Select Case Item(I).Type

Case ITEM_TYPE_WEAPON
WeaponNum = I

Case ITEM_TYPE_HELMET
HelmetNum = I

Case ITEM_TYPE_ARMOR
ArmorNum = I

Case ITEM_TYPE_SHIELD
ShieldNum = I

End Select
End If
End If
        End If
Next I

DropNum = Rand(1, 4)

'Randomly drop the item of it's item type.
Select Case DropNum

Case 1
Call SpawnItem(WeaponNum, 1, MapNum, NPCx, NPCy)

Case 2
Call SpawnItem(HelmetNum, 1, MapNum, NPCx, NPCy)

Case 3
Call SpawnItem(ArmorNum, 1, MapNum, NPCx, NPCy)

Case 4
Call SpawnItem(ShieldNum, 1, MapNum, NPCx, NPCy)

End Select
End If
End Sub

```
Then we just place this in PlayerAttackNPC, Look for this;

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

```
Underneath, put this in;

```
'Prevent camping on low level NPC's
If Npc(npcNum).level >= GetPlayerLevel(Attacker) Then
Call RareItem(Attacker, GetPlayerLevel(Attacker), GetPlayerClass(Attacker), mapnum, MapNpc(mapnum).Npc(mapNpcNum).x, MapNpc(mapnum).Npc(mapNpcNum).y)
End If

```
Let me know if everything's cool with it if you try it.
Credits aren't needed for this in any game project.
Link to comment
Share on other sites

Example

```
Select Case Index
    Case 1
          PlayerMsg Index, "You are player number 1.", White
    Case 2
          PlayerMsg Index, "You are player number 2.", White
    Case 3
          PlayerMsg Index, "You are player number 3.", White
End Select
```
Use the tab key. Makes it WAY easier to read, and also makes it easier to think about how it'd work, and think about what runs when.
Link to comment
Share on other sites

Sorry I freetyped this cause my visual basic isn't letting me copy the code from inside of it for some unknown reason, and the tab key isn't gonna let me do it in this post so :(

Well hell I learned something new today lol. I didn't think it really mattered. I'll copy and paste in notepad and nest it then.
Link to comment
Share on other sites

No problem.

@Glenn, I didn't even know what nesting meant until Serenade told me, Lol @ me with my fail of 'trying' to play off Robin;

@Richy:

> I thought it was. :(. What you mean?

Though yes I'll make sure to nest anything from now on. I've already started in VB to do it but I still can't copy out of VB into notepad, wordpad or on the internet. Clipbook be saying that I ain't got enough memory like damn, my computer is starting a slow painful death.
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...