Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making advanced items
#1
I noticed that the items are barren. There's no stats for them whatsoever, can anyone post a tut or maybe steer me in the right direction? I thought of ripping it from Elysium, but... No. Just no.
Reply
#2
Do you mean Item requirements? Or something like adding STR, DEF ect.?
Reply
#3
Required stats, item stats, attack modifiers, etc, etc.
Reply
#4
What I need is a Level Requirement and class requirement thing for items.
Reply
#5
Just add the new thing you want to the item UDT then add a box or scrollbar or whatever to the item editor, parse everything properly and make it save right. Then just whenever a player goes to equip something have it check if they are the correct level or class by calling to the saved item. Pretty simple.

If you want item bonuses it's like the same way more or less just when you have the getplayerstats check, look to see if they are wearing any items that may increase their stat points and if so just add it in.
Reply
#6
Asrrin29 Wrote:Something like this?

[Image: MainScreen.PNG]
[Image: Item%20Editor.PNG]

Yes, that's very sexy.

Thanks for the suggestions, everyone. I'll get to work soon. Smile
Reply
#7
Exactly like that, with the class and level req.
Reply
#8
Wow, that's way to complicated for me. Need to get better at coding first.
Reply
#9
Asrrin made it sound way more complicated than it actually is haha.

Add this to your ItemRec UDT on client and server side.

Code:
Stat(1 To Stats.Stat_Count - 1) As Byte

Then parse the data back and forth properly and have it all save and make it work with the editor.

On the server side find the GetPlayerStat function and make it look like this.

Code:
Public Function GetPlayerStat(ByVal Index As Long, ByVal Stat As Stats) As Long
Dim Add As Long, i As Long

    Add = 0

    For i = 1 To Equipment.Equipment_Count - 1
        If GetPlayerEquipmentSlot(Index, i) > 0 Then
            Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerEquipmentSlot(Index, i))).Stat(Stat)
        End If
    Next i

    GetPlayerStat = Player(Index).Char(TempPlayer(Index).CharNum).Stat(Stat) + Add
End Function

That's how I did mine. So if you have any item equipped it checks for any bonuses that have been added then just adds it to the stat. This works in MS4.
Reply
#10
Thx, umm how do you "parse" stuff?
Reply
#11
Basically it's just transferring data between a server and client.

So in modHandleData you can see that in the HandleEditItem sub the client is receiving data from the server and organizing it to it's appropriate defined types. If you look on the server side for the part of it that sends the data to the client you'll see how it's setup.

So in modServerTCP on the server you can see the SendEditItemTo sub and how it's sending the data. Keep it all organized and in order and it's pretty easy.

I might write a tutorial on this advanced items thing but don't count on it. I just almost have in this topic Tongue.
Reply
#12
Here's a sub I have to see if you can use an item:

In the item UDT:
Code:
LevelReq As Long
    ClassReq(0 To MAX_CLASSES) As Byte
    StatReq(1 To Stats.Stat_Count - 1) As Byte

Code:
'***************************************
' Check to see if you can use an item
'***************************************
Public Function CanUseItem(ByVal Index As Long, ByVal ItemNum As Long) As Boolean
Dim i As Long

    CanUseItem = False
    
    ' Check for level requirement
    If Item(ItemNum).LevelReq > 0 Then
        ' If there's a level requirement then check if you can use it
        ' Checks if your level is below the req and if so - will exit
        If Current_Level(Index) < Item(ItemNum).LevelReq Then
            SendActionMsg Current_Map(Index), "[Level Req: " & Item(ItemNum).LevelReq & "]", ActionColor, ACTIONMSG_SCREEN, 0, 0, Index
            Exit Function
        End If
    End If
    
    ' Check for class requirement
    ' Will check your current class to the item
    ' If your class is 0 then that means you can not use the item so we exit
    If Item(ItemNum).ClassReq(Current_Class(Index))  0 Then
            If Current_BaseStat(Index, i) < Item(ItemNum).StatReq(i) Then
                SendActionMsg Current_Map(Index), "[" & StatName(i) & " req: " & Item(ItemNum).StatReq(i) & "]", ActionColor, ACTIONMSG_SCREEN, 0, 0, Index
                Exit Function
            End If
        End If
    Next
    
    ' If we get through all the checks it means we can use the item
    CanUseItem = True
End Function
Reply
#13
OK, I'm starting to understand it better now. Thanks Dugor, that sub really helped me figure things out.
Reply
#14
Anthony Wrote:Asrrin made it sound way more complicated than it actually is haha.

Add this to your ItemRec UDT on client and server side.

Code:
Stat(1 To Stats.Stat_Count - 1) As Byte

Then parse the data back and forth properly and have it all save and make it work with the editor.

On the server side find the GetPlayerStat function and make it look like this.

Code:
Public Function GetPlayerStat(ByVal Index As Long, ByVal Stat As Stats) As Long
Dim Add As Long, i As Long

    Add = 0

    For i = 1 To Equipment.Equipment_Count - 1
        If GetPlayerEquipmentSlot(Index, i) > 0 Then
            Add = Add + Item(GetPlayerInvItemNum(Index, GetPlayerEquipmentSlot(Index, i))).Stat(Stat)
        End If
    Next i

    GetPlayerStat = Player(Index).Char(TempPlayer(Index).CharNum).Stat(Stat) + Add
End Function

That's how I did mine. So if you have any item equipped it checks for any bonuses that have been added then just adds it to the stat. This works in MS4.

Thanks a lot dude, this really helped me out. Could you give an example of parsing one of the stats though? It might be that I'm missing something obvious, or the fact it's two in the morning, but that's the only thing I have a problem understanding. If I can get that, than I think I can definitely program this in myself... Than again, that's the biggest part. xD
Reply
#15
Parsing for the item editor? This is a sub here.

Code:
Sub SendUpdateItemToAll(ByVal ItemNum As Long)
Dim Packet As String, i As Byte

With Item(ItemNum)
    Packet = SUpdateItem & SEP_CHAR & ItemNum & SEP_CHAR & Trim$(.Name) & SEP_CHAR & .Pic & SEP_CHAR & .Type
    
    For i = 1 To Stats.Stat_Count - 1
        Packet = Packet & SEP_CHAR & .Stat(i)
    Next i

    Packet = Packet & SEP_CHAR & .Exp & SEP_CHAR & .Gold & END_CHAR
End With
    Call SendDataToAll(Packet)
End Sub

Then for receiving it in the client.

Code:
Sub HandleUpdateItem(ByRef Parse() As String)
Dim n As Long, ItemNum As Long, i As Byte

    ItemNum = Val(Parse(1))
    
    ' Update the item
    Item(ItemNum).Name = Parse(2)
    Item(ItemNum).Pic = Val(Parse(3))
    Item(ItemNum).Type = Val(Parse(4))
    Item(ItemNum).Data1 = 0
    Item(ItemNum).Data2 = 0
    Item(ItemNum).Data3 = 0
    
    n = 5
    For i = 1 To Stats.Stat_Count - 1
        Item(ItemNum).Stat(i) = Val(Parse(n))
        
        n = n + 1
    Next i

End Sub

Or are you talking about sending the data to the client so you can have it displayed as like a 10 + (2) sort of thing?
Reply
#16
Those subs would go in modgamelogic right?
Reply
#17
Gah, I just I don't understand how to actually add the stats to the items.
Reply
#18
I understand setting requirements, but not making the items add stats. I guess it would be like a spell Buff maybe.
Reply
#19
If weapon(getplayerweapon(myindex)).bonusstr > 0 then
call setplayertempstr(myindex, getplayerstr(myindex))
call setplayerstr(myindex, getplayerstr(myindex) + weapon(getplayerweapon(myindex)).bonusstr)
end if

Something along that, pending how you store the item's bonus stats and such.
Reply
#20
I don't see how much better we can explain it O_o haha.
Reply
#21
Holy fucking shit, i was retarded. I worked on this tonight, and actually thought about it, and it was incredibly simple. Well at least the item requirements are, I have yet to do the stat modifiers. Thanks for all the help guys. Big Grin
Reply
#22
Really? Then I'm gonna try it as well.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)