Item System

From HEWIKI
Revision as of 19:59, 12 September 2011 by Alex (Talk | contribs)
Jump to: navigation, search

He intermediate.png

This page documents an upcoming feature.

Contents

Overview

The Item System provides a way to create and store objects within the game world that can be collected by players. The Item System uses the Spec System to design an instantiate Items, Item Containers and Item Appearances. There is also the Item Category and Currency Spec Oracles used by the Item System for Item spec decorators, however no nodes are instantiated from them.


What Issue(s) Does This Address?


What Issue(s) Does This NOT Address?


Architecture

(need a pretty picture)

Item Container Owner

Only an Item Container Owner can have Item Container's. Currently Item Container Owners must also be derived from _PlayerCharacter. If the Item System is being used in a game then all characters will also be Item Container Owners. Item Containers are stored on a Item Container Owner in a map where the key is the Item Container name and the value is the Item Container's ID. Therefore an Item Container Owner can only have one Item Container with a given name. Item Container Owners provide the functionality to add and remove Item Containers from themselves.

Item Container

Item Containers are created by the Item Container Spec oracle and stored by name on a Item Container Owner. Items are stored on a Item Container in a map where the key is the ID of the Item and the value is a NodeRef to the Item. Item Containers provide the functionality to add and remove Items from themselves. Each Item Container is the primary node in it's own replication group which means Items are replicated from server to client by that Item's Container.

Item

Items are decorated by the spec system to give them additional data to describe them as well as specialized functionality. An example is the Value Item decorator which gives the Item arbitrary values in various currencies stored in a map. The Currency spec oracle is used to define the currencies. The base Item class provides an interface to send a number of events that Item decorator classes can respond to. Some of the Item events decorators can respond to include Acquired, Lost, Activated, Used, Equipped and Unequipped.

Item Appearance

Item appearances are used to visualize an Item in the game world. Items that can be visualized have either the Single or Multiple Visualization Item decorator glommed on in the glom menu of the Item Spec Oracle Editor. Item Appearances are replicated in the replication group of the Player Account node of the Item Container Owner. There are three ways Items are visualized: dynamic parts swapping, bone tracker node with an attached prop bucket instance and the behave hold command with a prop bucket instance.


Usage

Giving Items to Player Characters

There are steps that need to be completed in order for Player Characters to have Items.

1. Create a new class in the server and client DOM that will be used as the Player Character class.
2. Add as parent classes _PlayerCharacter and _ItemContainerOwner.
3. Create a prototype from this new Player Character class.
4. Override HE_CSSUseCharacterPrototype in the class methods script of a new or existing class. Return as a reference a noderef of the prototype that was previously created and return true.
5. Using the System Node Configuration GUI add to the server Character Selection System the class which contains the override of HE_CSSUseCharacterPrototype.
6. Destroy existing account root nodes by calling _DestroyAccountRootNode on the $ACCOUNT system node. The next time that account logs into HeroBlade and creates a new character, that character will be able to own Item Containers and Items.

Creating Items

See the Spec Oracle Editor page for information on basic usage of the Spec Oracle Editor.

Which Item Visualization to use


Adding or Removing an Item Container

Adding or Removing an Item


On the Client

Most of the client interaction with the Item System takes place on Items and Item Containers. The server is the authoritative source for manipulating Items and sending Item events. The client interfaces for Items and Item Containers have methods that request the server to do things instead of interacting with Items on the client and replicating data up to the server.



Concepts


Advanced Usage

Creating New Decorators

New Item Events

Method Breakdown

The following is a method break down of important Item related classes, that can be extended via overloading.

_ItemSystem

unique method _CreateItemFromSpecKey(specKey as ID) as NodeRef of Class _Item

unique method _CreateItemContainerFromSpecKey(specKey as ID) as NodeRef of Class _ItemContainer

unique method _CreateItemApperanceFromSpecKey(specKey as ID) as NodeRef of Class _ItemAppearance

unique method _ItemSystemSpecOracleGetValidBaseClasses(valid references List of String)

unique method _ItemSystemSpecOracleGetSpecDecoratorClasses(valid references List of String)
_ItemContainerOwner

method _GetItemContainerByName(containerName as String) as ID

method _GetAllItemContainerNames() as List of String

method _HasItemContainerByName(containerName as String) as Boolean

method _AddItemContainer(newContainer as NodeRef of Class _ItemContainer)

method _RemoveItemContainerByName(containerName as String) as NodeRef of Class _ItemContainer
_ItemContainer

method _GetItemContainerName() as String

method _SetItemContainerName(newContainerName as String)

method _GetItemContainerOwner() as NodeRef of Class _ItemContainerOwner

method _SetItemContainerOwner(newContainerOwner as ID)

method _CanAddItemToContainer(item_to_add as NodeRef of Class _Item) as Boolean

method _AddItemToContainer(item_to_add as NodeRef of Class _Item) as Boolean

untrusted method _RequestedAddItemToContainer(item_to_add as ID)

method _CanRemoveItemFromContainer(item_to_remove as NodeRef of Class _Item) as Boolean

method _RemoveItemFromContainer(item_to_remove as NodeRef of Class _Item) as Boolean

untrusted method _RequestedRemoveItemFromContainer(item_to_remove as ID)

method _GetItemContainerMaxContainedItems() as Integer

method _GetNumberOfContainedItems() as Integer

method _ItemContainerHasSpareSpace() as Boolean

method _HasContainedItemByID(containedItem as ID) as Boolean

method _GetAllContainedItemsBySpecKey( spec_key as ID ) as List of NodeRef of Class _Item
_Item

method _GetItemContainerID() as ID

method _GetItemOwnerID() as ID

method _SetItemContainer(newContainer as ID)


Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox