[EO] Container item type (gambling)

Goal

Creating a new item type, “container”, that can contain upto 5 different items (currenly only awards a max of 1 per item, so not really great for gold, prob one of the things you should change if you want to use this) Containers work just like other items in the sense that they have a picture, they can have requirements such as level, class, admin access, or stats and they obviously have a pic/description.

Client + serverside

In Private Type ItemRec add

    Container(0 To 4) As Long
    ContainerChance(0 To 4) As Byte
```to the bottom.

Under Public Const ITEM_TYPE_SPELL As Byte = 8 Add

Public Const ITEM_TYPE_CONTAINER As Byte = 9


**Client**
All of this is in frmEditor_Item

Add a fraContainer. This frame should be on top of FraEquipment. In this frame, add 2 textboxes. Name them TxtContainerItem and TxtContainerChance. Copy each box 4 times so you end up with a total of 10 boxes. VB will ask you if you want to create an array, click yes. Also add labels that identify what box is what so people who work on your game know how to use it. Doesn't matter what you name them. Make it look pretty.

On CmbType add Container to the List setting and add a 0 to the Itemdata. Now doubleclick CmbType and add just above    Item(EditorIndex).Type = cmbType.ListIndex the following code

If (cmbType.ListIndex = ITEM_TYPE_CONTAINER) Then
        FraContainer.Visible = True
    Else
        FraContainer.Visible = False
    End If

Also in frmEditor_Item, add the following code to the bottom of the sub

Private Sub TxtContainerChance_Change(Index As Integer)
    ’ If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler
    If EditorIndex = 0 Or EditorIndex > MAX_ITEMS Or TxtContainerChance(Index) > 100 Or TxtContainerChance(Index) < 1 Then Exit Sub

If IsNumeric(Index) Then
        Item(EditorIndex).ContainerChance(Index) = TxtContainerChance(Index)
    Else
        MsgBox (“Trying to enter a string is a dickmove, 1-100 (percentages) only!”)
    End If

’ Error handler
    Exit Sub
errorhandler:
    HandleError “txtDesc_Change”, “frmEditor_Item”, Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

Private Sub TxtContainerItem_Change(Index As Integer)
    ’ If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler
    If EditorIndex = 0 Or EditorIndex > MAX_ITEMS Or TxtContainerItem(Index) > MAX_ITEMS Or TxtContainerItem(Index) < 0 Then Exit Sub

If IsNumeric(Index) Then
        Item(EditorIndex).Container(Index) = TxtContainerItem(Index)
    Else
        MsgBox (“Trying to enter a string is a dickmove, item numbers only!”)
    End If

’ Error handler
    Exit Sub
errorhandler:
    HandleError “txtDesc_Change”, “frmEditor_Item”, Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

In ItemEditorInit, under       ```
 If (frmEditor_Item.cmbType.ListIndex = ITEM_TYPE_SPELL) Then
            frmEditor_Item.fraSpell.Visible = True
            frmEditor_Item.scrlSpell.Value = .Data1
        Else
            frmEditor_Item.fraSpell.Visible = False
        End If

add

        If (frmEditor_Item.cmbType.ListIndex = ITEM_TYPE_SPELL) Then
            frmEditor_Item.fraSpell.Visible = True
            frmEditor_Item.scrlSpell.Value = .Data1
        Else
            frmEditor_Item.fraSpell.Visible = False
        End If

In the server, in use item, under Select Case Item(itemnum).Type add

            Case ITEM_TYPE_CONTAINER

                ' stat requirements
                For I = 1 To Stats.Stat_Count - 1
                    If GetPlayerRawStat(Index, I) < Item(itemnum).Stat_Req(I) Then
                        PlayerMsg Index, "You do not meet the stat requirements to equip this item.", BrightRed
                        Exit Sub
                    End If
                Next

                ' level requirement
                If GetPlayerLevel(Index) < Item(itemnum).LevelReq Then
                    PlayerMsg Index, "You do not meet the level requirement to equip this item.", BrightRed
                    Exit Sub
                End If

                ' class requirement
                If Item(itemnum).ClassReq > 0 Then
                    If Not GetPlayerClass(Index) = Item(itemnum).ClassReq Then
                        PlayerMsg Index, "You do not meet the class requirement to equip this item.", BrightRed
                        Exit Sub
                    End If
                End If

                ' access requirement
                If Not GetPlayerAccess(Index) >= Item(itemnum).AccessReq Then
                    PlayerMsg Index, "You do not meet the access requirement to equip this item.", BrightRed
                    Exit Sub
                End If

                PlayerMsg Index, "You open up the " & Item(itemnum).Name, Green
                For I = 0 To 4
                    If Item(itemnum).Container(I) > 0 Then
                        X = Random(0, 100)
                        If X =< Item(itemnum).ContainerChance(I) Then
                            'Award item
                            Call GiveInvItem(Index, Item(itemnum).Container(I), 0)
                            PlayerMsg Index, "You discover a " & Item(Item(itemnum).Container(I)).Name, Green
                        End If
                    End If
                Next I

                TakeInvItem Index, itemnum, 0

And we’re done. Voila. If you encounter any problems, try deleting your items first. There are some player messages in there, feel free to adjust those. The green is also very ugly, imo.

Source code so if you want an example of FraContainer. Also includes my taunt/aggro stuff, but just ignore that. Server has an account named 1234 with password 1234 if you want to test it out. Run it from the source files, i did not compile new exe’s.

Hmm?? Wrong code?

This part:

In [background=yellow]Item[/background]EditorInit, under

**```

If (frmEditor_Item.cmbType.ListIndex = ITEM_TYPE_SPELL) Then

	 frmEditor_Item.fraSpell.Visible = True

	 frmEditor_Item.scrlSpell.Value = .Data1

 Else

	 frmEditor_Item.fraSpell.Visible = False

 End If

**add**

**```

If (frmEditor_Item.cmbType.ListIndex = ITEM_TYPE_SPELL) Then

		 frmEditor_Item.fraSpell.Visible = True

		 frmEditor_Item.scrlSpell.Value = .Data1

	 Else

		 frmEditor_Item.fraSpell.Visible = False

	 End If

```**

You should edit this part.

Is like a bag?

No, more like a treasure chest of limited randomness. You enter 5 pairs of a percentage and an item to give. When the player opens the box, they have a percentage chance to get each item. Like the lucky boxes in RO.

No, more like a treasure chest of limited randomness. You enter 5 pairs of a percentage and an item to give. When the player opens the box, they have a percentage chance to get each item. Like the lucky boxes in RO.

a hahaha good job i will add in my game ;) Thanks Good idea

Log in to reply