Items that make you warp

From VbGORE Visual Basic Online RPG Engine

[edit] Feature [Item-Warping]


First, Find Public Sub User_UseInvItem(ByVal UserIndex As Integer, ByVal Slot As Byte) in GameServer.vbp Users module Add The Following

Dim tpos As WorldPos
Dim npos As WorldPos
If ObjData.WarpMap(ObjIndex) > 0 Then
If Server_LegalPos(ObjData.WarpMap(ObjIndex), ObjData.WarpX(ObjIndex), ObjData.WarpY(ObjIndex), 1) Then
 
User_WarpChar UserIndex, ObjData.WarpMap(ObjIndex), ObjData.WarpX(ObjIndex), ObjData.WarpY(ObjIndex), False
 
Else
tpos.Map = ObjData.WarpMap(ObjIndex)
tpos.X = ObjData.WarpX(ObjIndex)
tpos.Y = ObjData.WarpY(ObjIndex)
Server_ClosestLegalPos tpos, npos
User_WarpChar UserIndex, npos.Map, npos.X, npos.Y, False
End If
End If

Next We need to get obj info in sql,
IN FileIO.bas Module Find Public Sub Load_OBJs() You may replace the whole sub with this, or just append the needed

 Do While Not DB_RS.EOF   'Loop until we reach the end of the recordset
        With TempObjData
            Log "Load_OBJs: Filling ObjData for object ID " & DB_RS!id, CodeTracker '//\\LOGLINE//\\
            .Name = Trim$(DB_RS!Name)
            .Value = Val(DB_RS!Price)
            .ClassReq = Val(DB_RS!ClassReq)
            .ObjType = Val(DB_RS!ObjType)
            .WeaponType = Val(DB_RS!WeaponType)
            .WeaponRange = Val(DB_RS!WeaponRange)
            .ProjectileRotateSpeed = Val(DB_RS!ProjectileRotateSpeed)
            .UseGrh = Val(DB_RS!UseGrh)
            .UseSfx = Val(DB_RS!UseSfx)
            .GrhIndex = Val(DB_RS!GrhIndex)
            .SpriteBody = Val(DB_RS!sprite_body)
            .SpriteWeapon = Val(DB_RS!sprite_weapon)
            .SpriteHair = Val(DB_RS!sprite_hair)
            .SpriteHead = Val(DB_RS!sprite_head)
            .SpriteWings = Val(DB_RS!sprite_wings)
            .RepHP = Val(DB_RS!replenish_hp)
            .RepMP = Val(DB_RS!replenish_mp)
            .RepSP = Val(DB_RS!replenish_sp)
            .RepHPP = Val(DB_RS!replenish_hp_percent)
            .RepMPP = Val(DB_RS!replenish_mp_percent)
            .RepSPP = Val(DB_RS!replenish_sp_percent)
            .AddStat(SID.Speed) = Val(DB_RS!stat_speed)
            .AddStat(SID.Str) = Val(DB_RS!stat_str)
            .AddStat(SID.Agi) = Val(DB_RS!stat_agi)
            .AddStat(SID.Mag) = Val(DB_RS!stat_mag)
            .AddStat(SID.DEF) = Val(DB_RS!stat_def)
            .AddStat(SID.MinHIT) = Val(DB_RS!stat_hit_min)
            .AddStat(SID.MaxHIT) = Val(DB_RS!stat_hit_max)
            .AddStat(SID.MaxHP) = Val(DB_RS!stat_hp)
            .AddStat(SID.MaxMAN) = Val(DB_RS!stat_mp)
            .AddStat(SID.MaxSTA) = Val(DB_RS!stat_sp)
            .ReqAgi = Val(DB_RS!req_agi)
            .ReqStr = Val(DB_RS!req_str)
            .ReqLvl = Val(DB_RS!req_lvl)
            .ReqMag = Val(DB_RS!req_mag)
            .Stacking = Val(DB_RS!Stacking)
            .WarpMap = Val(DB_RS!WarpMap)
            .WarpX = Val(DB_RS!WarpX)
            .WarpY = Val(DB_RS!WarpY)
            If .Stacking < 1 Then .Stacking = MaxObjAmount
        End With
 
        'Save the file
        FileNum = FreeFile
        Open ServerTempPath & "o" & DB_RS!id & ".temp" For Binary Access Write As #FileNum
            Put #FileNum, , TempObjData
        Close #FileNum
 
        'Move to the next object
        DB_RS.MoveNext
 
    Loop

The Needed things is (You may choose to paste)

            .WarpMap = Val(DB_RS!WarpMap)
            .WarpX = Val(DB_RS!WarpX)
            .WarpY = Val(DB_RS!WarpY)

Next Find Declares Module in GameServer.vbp

Public Type udtObjData
    Name As String                  'Name
    ObjType As Byte                 'Type (armor, weapon, item, etc)
    ClassReq As Integer             'Class requirement
    GrhIndex As Long                'Graphic index
    SpriteBody As Integer           'Index of the body sprite to change to
    SpriteWeapon As Integer         'Index of the weapon sprite to change to
    SpriteHair As Integer           'Index of the hair sprite to change to
    SpriteHead As Integer           'Index of the head sprite to change to
    SpriteWings As Integer          'Index of the wings sprite to change to
    WeaponType As Byte              'What type of weapon, if it is a weapon
    WeaponRange As Byte             'Range of the weapon (only applicable if a ranged WeaponType)
    UseGrh As Long                  'Grh of the object when used (projectile for ranged, slash for melee, effects for use-once)
    UseSfx As Byte                  'Sound effect played when the object is used (based on the .wav's number)
    ProjectileRotateSpeed As Byte   'How fast the projectile rotates (if at all)
    Value As Long                   'Value of the object
    RepHP As Long                   'How much HP to replenish
    RepMP As Long                   'How much MP to replenish
    RepSP As Long                   'How much SP to replenish
    RepHPP As Integer               'Percentage of HP to replenish
    RepMPP As Integer               'Percentage of MP to replenish
    RepSPP As Integer               'Percentage of SP to replenish
    ReqStr As Long                  'Required strength to use the item
    ReqAgi As Long                  'Required agility
    ReqMag As Long                  'Required magic
    ReqLvl As Long                  'Required level
    Stacking As Integer             'How much the item can be stacked up (-1 for no limit, 0 for
    AddStat(FirstModStat To NumStats) As Long   'How much to add to the stat by the SID
    Pointer As Integer
End Type

Append This

    WarpMap As Integer
    WarpX As Byte
    WarpY As Byte

TO The End


Next, Go to ObjData.Cls Add This

    Public Property Get WarpMap(ByVal Index As Integer) As Byte
    If Index > 0 Then
        If Index <= MaxDatas Then
            ReadyObj Index
            WarpMap = cData(ObjIndexToDataIndex(Index)).WarpMap
        End If
    End If
End Property
Public Property Get WarpX(ByVal Index As Integer) As Byte
    If Index > 0 Then
        If Index <= MaxDatas Then
            ReadyObj Index
            WarpX = cData(ObjIndexToDataIndex(Index)).WarpX
        End If
    End If
End Property
Public Property Get WarpY(ByVal Index As Integer) As Byte
    If Index > 0 Then
        If Index <= MaxDatas Then
            ReadyObj Index
            WarpY = cData(ObjIndexToDataIndex(Index)).WarpY
        End If
    End If
End Property

Finally, Add the following to your database.Object

WarpX
WarpY
WarpMap

Now edit the warpmap, warpx and warpy to consider which place you want to send the player to, warpmap=0 means close function

Feel Free to edit it until you think it is good, or adding some particles effect as you like ^^ '

Personal tools