Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[eo] Chest Attribute


kibbelz
 Share

Recommended Posts

Hey, This is just a conversion of the chest attribute system from [ES]. Most of you know what it does already. It it is a chest attribute for the map editor and when you press enter on it (like items on the ground) it picks it up. But chests can only be opened once. So this stops players picking up a special prize from a cave or somethingĀ  ;)

Anyway lets start with the **Client side**

Form work:
The only form work you will need here is to add an option button called "OptChest" to frmeditor_map

Double click on OptChest and add:

```
Private Sub OptChest_Click()
Ā  Ā  ClearAttributeDialogue
Ā  Ā  picAttributes.Visible = True
Ā  Ā  fraMapItem.Visible = True

Ā  Ā  scrlMapItem.Max = MAX_ITEMS
Ā  Ā  scrlMapItem.Value = 1
Ā  Ā  lblMapItem.Caption = Trim$(Item(scrlMapItem.Value).Name) & " x" & scrlMapItemValue.Value
Ā  Ā  EditorMap_BltMapItem
End Sub
```
Now for the code:

In modConstants find:

```
Public Const TILE_TYPE_SLIDE As Byte = 14
```
And add under:
```
Public Const TILE_TYPE_CHEST As Byte = 15
```
Then, in modgameeditors Find:
```
Ā  Ā  Ā  Ā  ' slide
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  If frmEditor_Map.optSlide.Value Then
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  .Type = TILE_TYPE_SLIDE
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  .Data1 = MapEditorSlideDir
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  .Data2 = 0
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  .Data3 = 0
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  End If
```
And underneath add:

```
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  'Chest
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  If frmEditor_Map.OptChest.Value Then
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  .Type = TILE_TYPE_CHEST
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  .Data1 = ItemEditorNum
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  .Data2 = ItemEditorValue
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  .Data3 = 0
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  End If
```
Next, in modtext Find:

```
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Case TILE_TYPE_SLIDE
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  DrawText TexthDC, tX, tY, "S", QBColor(BrightCyan)
```
and then add underneath:

```
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Case TILE_TYPE_CHEST
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  DrawText TexthDC, tX, tY, "C", QBColor(Brown)
```
Thats it for client side!

Now for **Server Side**

In ModConstants find:

```
Public Const TILE_TYPE_SLIDE As Byte = 14
```
And after that add:

```
Public Const TILE_TYPE_CHEST As Byte = 15
```
Next in ModHandleData find: Sub HandleMapGetItem And replace the entire sub with:

```
Sub HandleMapGetItem(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddR As Long, ByVal ExtraVar As Long)
Ā  Ā  Dim b As Long

Ā  Ā  If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_CHEST Then
Ā  Ā  Ā  Ā  If Val(GetVar("data\chests\" & Trim(GetPlayerName(index)) & ".ini", "Chests_Map_" & Trim(STR(GetPlayerMap(index))), Trim(STR(GetPlayerX(index))) & "_" & Trim(STR(GetPlayerY(index))))) = 0 Then
Ā  Ā  Ā  Ā  Ā  Ā  b = FindOpenInvSlot(index, Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).data1)
Ā  Ā  Ā  Ā  Ā  Ā  Call PlayerMsg(index, "You opened the chest and found " & Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).data2 & " " & Item(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).data1).Name, White)
Ā  Ā  Ā  Ā  Ā  Ā  Call SetPlayerInvItemNum(index, b, Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).data1)
Ā  Ā  Ā  Ā  Ā  Ā  ' Fixed by Yami, the main issue here was that he was simply assigning the value the chest should give, not adding it to the existing value.
Ā  Ā  Ā  Ā  Ā  Ā  Call SetPlayerInvItemValue(index, b, GetPlayerInvItemValue(index, b) + Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).data2)
Ā  Ā  Ā  Ā  Ā  Ā  Call PutVar("data\chests\" & Trim(GetPlayerName(index)) & ".ini", "Chests_Map_" & Trim(STR(GetPlayerMap(index))), Trim(STR(GetPlayerX(index))) & "_" & Trim(STR(GetPlayerY(index))), "1")
Ā  Ā  Ā  Ā  Ā  Ā  Call SendInventoryUpdate(index, b)
Ā  Ā  Ā  Ā  Else
Ā  Ā  Ā  Ā  Ā  Ā  Call PlayerMsg(index, "You have already looted this chest!", BrightRed)
Ā  Ā  Ā  Ā  End If
Ā  Ā  Else
Ā  Ā  Ā  Ā  Call PlayerMapGetItem(index)
Ā  Ā  End If
End Sub
```
Be sure to add a new folder in your Server\Data folder called Chests, this is where the INI files will be stored!

-Added the fixed sub and removed his personal bullcrap INI commands. Guys, GetVar does NOT error on empty values unless you screw it over sideways. Currencies will now properly stack, instead of being replaced.

-Yami
Link to comment
Share on other sites

  • Replies 65
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 month later...
  • 3 weeks later...
hmm well at the moment all this does is give you the item once. It doesn't make the chest open and close etc. So just do a closed chest for now untill i or someone else can be botherd to ad opening and closing chests.
Link to comment
Share on other sites

@kibbelz:

> hmm well at the moment all this does is give you the item once. It doesn't make the chest open and close etc. So just do a closed chest for now untill i or someone else can be botherd to ad opening and closing chests.

ahh ok thanks, i will add this on my game.
Link to comment
Share on other sites

  • 2 weeks later...
@Raiko.:

> what do you mean behind the slide button you just have to make a button under the slide button in your map editor using the tool box

Like i say you have to add it to the frm Map Editor using the vb6 tool box and check if your button visible = true
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...