Mirage Source
http://web.miragesource.net/forums/

Making advanced items
http://web.miragesource.net/forums/viewtopic.php?f=210&t=4957
Page 1 of 2

Author:  Nean [ Tue Jan 13, 2009 9:52 pm ]
Post subject:  Making advanced items

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.

Author:  timster0 [ Thu Jan 15, 2009 12:14 am ]
Post subject:  Re: Making advanced items

Do you mean Item requirements? Or something like adding STR, DEF ect.?

Author:  Nean [ Thu Jan 15, 2009 4:09 am ]
Post subject:  Re: Making advanced items

Required stats, item stats, attack modifiers, etc, etc.

Author:  timster0 [ Fri Jan 16, 2009 12:51 am ]
Post subject:  Re: Making advanced items

What I need is a Level Requirement and class requirement thing for items.

Author:  Anthony [ Fri Jan 16, 2009 1:22 am ]
Post subject:  Re: Making advanced items

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.

Author:  Asrrin29 [ Fri Jan 16, 2009 5:29 pm ]
Post subject:  Re: Making advanced items

Something like this?

Image
Image

Author:  Nean [ Fri Jan 16, 2009 10:14 pm ]
Post subject:  Re: Making advanced items

Asrrin29 wrote:
Something like this?

Image
Image


Yes, that's very sexy.

Thanks for the suggestions, everyone. I'll get to work soon. :)

Author:  timster0 [ Fri Jan 16, 2009 11:14 pm ]
Post subject:  Re: Making advanced items

Exactly like that, with the class and level req.

Author:  Asrrin29 [ Fri Jan 16, 2009 11:32 pm ]
Post subject:  Re: Making advanced items

timster0 wrote:
Exactly like that, with the class and level req.



I reworked the ENTIRE item stats code to get this to work. you basically start with the basics, adding in every variable you want to items, saving them server side, and passing the variables between server and client. add to the editor client side. once you have the variables being passed back and forth successfully, then you need to actually make the variables do something. I found it very frustrating to find every instance of when a player has items being removed or added, so instead of finding them all I did stat checks straight in the player's GetStat subs. If for some reason I needed to find the player's natural stat I just used Player(I).Stat(whatever). (I'm psuedo-coding it heavy right there, but you get the picture.) For other types of stats, such as life stealing, crit%, etc. I added the proper subs into the attack code. I reccommend using case statements, because If/Then/Else will get very messy in very short order.

The Item pop-up code was quicker but a little more difficult, I passed all the variables to the client every time it asked to see them, and used a transparent richtextbox and formatted it based on the stats I had. That is why you don't see empty fields (like Level Req, because that particular item has no level req).

Author:  timster0 [ Sat Jan 17, 2009 12:45 am ]
Post subject:  Re: Making advanced items

Wow, that's way to complicated for me. Need to get better at coding first.

Author:  Anthony [ Sat Jan 17, 2009 1:37 am ]
Post subject:  Re: Making advanced items

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.

Author:  timster0 [ Sat Jan 17, 2009 1:51 am ]
Post subject:  Re: Making advanced items

Thx, umm how do you "parse" stuff?

Author:  Anthony [ Sat Jan 17, 2009 1:59 am ]
Post subject:  Re: Making advanced items

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 :P.

Author:  Asrrin29 [ Sat Jan 17, 2009 2:59 am ]
Post subject:  Re: Making advanced items

well, for my code it is a bit more complicated, because one I don't have a .stats, I have .STR, .DEX, etc. Second, in addition to the four basic stats I have MP, SP, HP, AP (Attack Power), RAP (Ranged Attack Power). so I have to use case statements.

Author:  Jacob [ Sat Jan 17, 2009 3:04 am ]
Post subject:  Re: Making advanced items

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
        SendActionMsg Current_Map(Index), "[Your class can not use this item.]", ActionColor, ACTIONMSG_SCREEN, 0, 0, Index
        Exit Function
    End If
   
    ' Check for stat requirement
    ' Will check all stats - if one isn't high enough will exit
    For i = 1 To Stats.Stat_Count - 1
        ' Make sure the stat has a requirement
        If Item(ItemNum).StatReq(i) > 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

Author:  timster0 [ Sat Jan 17, 2009 3:55 am ]
Post subject:  Re: Making advanced items

OK, I'm starting to understand it better now. Thanks Dugor, that sub really helped me figure things out.

Author:  Nean [ Sun Jan 18, 2009 9:00 am ]
Post subject:  Re: Making advanced items

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

Author:  Anthony [ Sun Jan 18, 2009 9:25 am ]
Post subject:  Re: Making advanced items

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?

Author:  timster0 [ Sun Jan 18, 2009 7:05 pm ]
Post subject:  Re: Making advanced items

Those subs would go in modgamelogic right?

Author:  Nean [ Sun Jan 18, 2009 7:32 pm ]
Post subject:  Re: Making advanced items

Gah, I just I don't understand how to actually add the stats to the items.

Author:  timster0 [ Tue Jan 20, 2009 12:58 am ]
Post subject:  Re: Making advanced items

I understand setting requirements, but not making the items add stats. I guess it would be like a spell Buff maybe.

Author:  Matt [ Tue Jan 20, 2009 4:52 am ]
Post subject:  Re: Making advanced items

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.

Author:  Anthony [ Tue Jan 20, 2009 6:26 am ]
Post subject:  Re: Making advanced items

I don't see how much better we can explain it O_o haha.

Author:  Nean [ Mon Jan 26, 2009 5:06 am ]
Post subject:  Re: Making advanced items

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. :D

Author:  timster0 [ Mon Jan 26, 2009 11:41 pm ]
Post subject:  Re: Making advanced items

Really? Then I'm gonna try it as well.

Page 1 of 2 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/