mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-20 07:27:19 -05:00
Feature/load misc items (#424)
* Add InventoryItemMisc struct * Add GetMiscItemByCode function * Implement InventoryItem interface for InventoryItemMisc * Add rings and amulets to the example items loading. * Fix Y of LeftHand and RightHand equipment slots. * Add "Ripolak" name to CONTRIBUTORS * Remove double item
This commit is contained in:
parent
897de61006
commit
f729ff6101
@ -16,6 +16,7 @@ Dylan "Gravestench" Knuth
|
||||
Intyre
|
||||
Gürkan Kaymak
|
||||
Maxime "malavv" Lavigne
|
||||
Ripolak
|
||||
|
||||
* DIABLO2 LOGO
|
||||
Jose Pardilla (th3-prophetman)
|
||||
|
64
d2core/d2inventory/inventory_item_misc.go
Normal file
64
d2core/d2inventory/inventory_item_misc.go
Normal file
@ -0,0 +1,64 @@
|
||||
package d2inventory
|
||||
|
||||
import (
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict"
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||
"log"
|
||||
)
|
||||
|
||||
type InventoryItemMisc struct {
|
||||
InventorySizeX int `json:"inventorySizeX"`
|
||||
InventorySizeY int `json:"inventorySizeY"`
|
||||
InventorySlotX int `json:"inventorySlotX"`
|
||||
InventorySlotY int `json:"inventorySlotY"`
|
||||
ItemName string `json:"itemName"`
|
||||
ItemCode string `json:"itemCode"`
|
||||
}
|
||||
|
||||
func GetMiscItemByCode(code string) *InventoryItemMisc {
|
||||
result := d2datadict.MiscItems[code]
|
||||
if result == nil {
|
||||
log.Fatalf("Could not find misc item entry for code '%s'", code)
|
||||
}
|
||||
return &InventoryItemMisc{
|
||||
InventorySizeX: result.InventoryWidth,
|
||||
InventorySizeY: result.InventoryHeight,
|
||||
ItemName: result.Name,
|
||||
ItemCode: result.Code,
|
||||
}
|
||||
}
|
||||
|
||||
func (v *InventoryItemMisc) InventoryItemName() string {
|
||||
if v == nil {
|
||||
return ""
|
||||
}
|
||||
return v.ItemName
|
||||
}
|
||||
|
||||
func (v *InventoryItemMisc) InventoryItemType() d2enum.InventoryItemType {
|
||||
return d2enum.InventoryItemTypeItem
|
||||
}
|
||||
|
||||
func (v *InventoryItemMisc) InventoryGridSize() (int, int) {
|
||||
return v.InventorySizeX, v.InventorySizeY
|
||||
}
|
||||
|
||||
func (v *InventoryItemMisc) InventoryGridSlot() (int, int) {
|
||||
return v.InventorySlotX, v.InventorySlotY
|
||||
}
|
||||
|
||||
func (v *InventoryItemMisc) SetInventoryGridSlot(x int, y int) {
|
||||
v.InventorySlotX, v.InventorySlotY = x, y
|
||||
}
|
||||
|
||||
func (v *InventoryItemMisc) Serialize() []byte {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
func (v *InventoryItemMisc) GetItemCode() string {
|
||||
if v == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return v.ItemCode
|
||||
}
|
@ -57,14 +57,14 @@ func genEquipmentSlotsMap() map[d2enum.EquippedSlotType]EquipmentSlot {
|
||||
d2enum.LeftHand: {
|
||||
item: nil,
|
||||
x: 491,
|
||||
y: 268,
|
||||
y: 270,
|
||||
width: 32,
|
||||
height: 32,
|
||||
},
|
||||
d2enum.RightHand: {
|
||||
item: nil,
|
||||
x: 606,
|
||||
y: 268,
|
||||
y: 270,
|
||||
width: 32,
|
||||
height: 32,
|
||||
},
|
||||
|
@ -65,6 +65,9 @@ func (g *Inventory) Load() {
|
||||
g.grid.ChangeEquippedSlot(d2enum.Legs, d2inventory.GetArmorItemByCode("vbt"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.Belt, d2inventory.GetArmorItemByCode("vbl"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.Gloves, d2inventory.GetArmorItemByCode("lgl"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.LeftHand, d2inventory.GetMiscItemByCode("rin"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.RightHand, d2inventory.GetMiscItemByCode("rin"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.Neck, d2inventory.GetMiscItemByCode("amu"))
|
||||
// TODO: Load the player's actual items
|
||||
g.grid.Add(items...)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user