Scripting Guide - Rare Item Drops from Monsters Script


This script will allow you to create the chance for monsters to drop rare items




First, you will have to create the RareDrop script

ex - "/god editscript raredrop"

Once you get the script opened, enter this code:

Sub Main(Player as Long, Chance as Long, Object as Long)
Dim X as Long, Y as Long

X = GetPlayerX(Player)
Y = GetPlayerY(Player)
If GetPlayerDirection(Player) = Up Then Y = Y - 1
If GetPlayerDirection(Player) = Down Then Y = Y + 1
If GetPlayerDirection(Player) = Left Then X = X - 1
If GetPlayerDirection(Player) = Right Then X = X + 1
If X < 0 | X > 11 Then X = GetPlayerX(Player)
If Y < 0 | Y > 11 Then Y = GetPlayerY(Player)
If GetTileAtt(GetPlayerMap(Player), X, Y) <> 0 Then
     X = GetPlayerX(Player)
     Y = GetPlayerY(Player)
End If

If Random(Chance) + 1 = 1 Then SpawnObject(GetPlayerMap(Player), Object, 1, X, Y)

End Sub


Now, you will need to edit the trigger event that happens when the specific monster dies

ex - "/god editscript monsterdie54"....(assuming you want monster #54 to drop the rare item)

Once you get the event opened, enter this code:

Function Main(Player as Long) as Long
dim Chance as Long, Object as Long

Chance = 75
Object = 354
RunScript3("RareDrop", Player, Chance, Object)

Main = Continue
End Function

It is pretty self explanatory, for "Chance" you will specify the percentage you want the item to drop, and "Object" you will specify what item number drops.