Item - 416rehman/mythic.obsidian GitHub Wiki

#gameplay #itemization

Anything the player can have in their inventory is called an Item. All items will have the following properties:

  • Name
  • Description
  • Type
  • Rarity
  • Mesh
  • Icon
  • bMarkedAsJunk (used if the item has a sellable or dismantleable component)

By default Items can only be:

  • Dropped: The item is dropped in the world, and can be picked up by the player.
  • Picked: The item is in the player's inventory, and the player can drop it.

The default events provided by an item are:

  • OnLooted: Fired when the player loots the item
  • OnDropped: Fired when the player drops the item

Components

Apart from all this, items do not contain much logic or functionality, we extend the functionality of items through composition, by adding components to items, such as:

Sellable

  • Price (calculated value), calculatePrice We can set a price for each item, or we can override the price through code calculations.

Stackable

  • StackSize This component allows multiple items to stack together into a single inventory slot, increasing the stack size of that item. SHOULD NOT BE USED WITH RNG / GEAR ITEMS.

Usable

  • PrimaryActionName, bConsumeOnPrimaryUse, OnPrimaryUse(), bCanQuickUse
  • SecondaryActionName, bConsumeOnSecondaryUse, OnSecondaryUse() This item can be used by the player when in their hotbar. The bConsumeOnPrimaryUse flag will destroy the item after the item has been used.The bCanQuickUse flag allows the player to use this item without having it in their hotbar or looted. Consider the following examples:
  1. Excalibur Sword

    • Sellable:
      • calculatePrice(): Calculate the price of the sword based on its power value.
    • Usable:
      • PrimaryActionName: Swing
      • bConsumeOnPrimaryUse: False
      • OnPrimaryUse(): Deals damage to enemies
      • bCanQuickUse: False
      • SecondaryActionName: None
      • bConsumeOnSecondaryUse: False
      • OnSecondaryUse(): None
  2. Water Bottle

    • Usable:
      • PrimaryActionName: Drink
      • bConsumeOnPrimaryUse: False
      • OnPrimaryUse(): Subtracts 1 from the water bottle's capacity.
      • SecondaryActionName: Refill
      • bConsumeOnSecondaryUse: False
      • OnSecondaryUse(): Adds 1 to the water bottle's capacity.
    • CapacityComponent:
      • Capacity: 5
      • MaxCapacity: 5
      • OnCapacityChanged(): Checks if the capacity has changed, and updates the player's thirst level accordingly.

Dismantleable

  • DismantleResult[{item, amount}]

EquippableComponent

Slot, OnEquipped() Allows the player to equip the gear on their character.


Base Classes

Using the components specified above, we can construct a variety of base classes for different kind of items in the game.

1. Gear

Wearable items and weapons are referred to as Gear in this game. Gear extends an item and has the following extra properties:

  • Base Attribute
  • Affixes
  • Talent
  • Power (calculated value)
  • SellableComponent
  • DismantleableComponent

Gear will have 2 subclasses:

Wearable Item

Wearable items require a slot to be put in, and cannot be interactively used by the player.

    • EquipableComponent (Slot: Head, Chest, Legs, Feet)

Weapon Item

Weapons do not have a specific slot like a wearable item, though they can be used by the player, for example, a sword can be swinged, a bow can be used to attack.

  • UsableComponent

2. Resource

Items that do not have any interactibility are called Resources, such as currencies, building materials and more.

All resources have the following components:

  • StackableComponent

Currencies

These items can be looted by the player and are visible on the player's hud, such as gold, premium currency etc.

⚠️ **GitHub.com Fallback** ⚠️