S2ENGINE HD 2023
User guide
×
Menu
Index

Items

Items are collectable objects that player can pick-up and store inside the inventory.
 
Basing on their types, items can be used, examined or both.
Some items can be equiped before being used, see Handling items.
 
Items are represented by two kind of scene objects:
 
 

Adding a new item
 
If you want to add an item in your game and allow player to pick-up it and store it into the inventory you need:
model parameter usually is not required by an itemObject.
For a complete overview of itemObject most important parameters see itemObject paragraph
 
 

Creating item logic
 
When an item is used (pressing the use command key in the inventory or on the HUD, see handling items ) an itemOIbject is instanced.
By default an ItemObject doesn't do anything but if you attach to it a GameMachine you can make it doing anything you want.
 
The following is the gameMachine of the health premade itemObject:
6.3.2. Items
1

Start state

1. Start state
As you can see there is only one state we called "standby" (but you can name it as you want) that is executed just when the itemObject starts to live.
Always use the start global transition to start a GameMachine. (see Global Transitions)
2

Get Player

2. Get Player
The first action that is executed by the "Standby" state is the GetPlayer that returns a reference (the name) of the player character.
3

Send message

3. Send message
Once we have got the reference to the player we can send it a message using the sendMessage action.
In this case the message is the "IncrementHealth" message (see player messages).
Amount is a parameter of the gameMachine we have created to allow user to set the amount of health the itemObject must restore.
4

Destroy

4. Destroy
Once the itemObject has done its job, we can destroy it, by using the SetFlags action with the parameter "died".
Always use setFlags action with died parameter when you want to destroy an object.
 
 

Included premade items
 
In the EasyGamePack DLC there are some "out of the box" items and GameMachines that you can used as starting point for your custom items.
 
Following is the list of most important GameMachines used for pre-made items that you can re-use for your needs:
Name
Location
Description
Parameters
map.gms
EasyGamePack/items
This is used for examining an item when it is stored into the inventory. When it is examined, an item can be rotated around a pivot point and moved to and from camera.
  • pivot_node: the node of the model used for representing the item you want to use as pivot for rotations (can be void)
  • pivot_ofs: offset from the pivot node origin (used for centering rotations)
  • min_zoom: minimum distance from camera the item can have during examination.
  • max_zoom: maximum distance from camera the item can have during examination.
  • start_zoom: starting distance from camera.
examineWhenTaken.gms
EasyGamePack/items
This is used for examining an item that isn't stored into the inventory but it is simply examined and then placed again in the same point it has been taken, see Examine only items. Its behaviour is same as map.gms
same as map.gms
key.gms
EasyGamePack/items
Used when you want to use a item as a key. See keys
nn
health.gms
EasyGamePack/items
Used when you want a item to restore player health
amount: health amount to increase
armor.gms
EasyGamePack/items
Used when you want a item to restore player armor
amount: armor amount to increase
ReleaseItem.gms
EasyGamePack/items
This is related to a more complex behaviour item. It is used on an itemObject that is linked to an examinable itemObject.
For example a cigarette pack containing a key (an itemTAG). The player can pick-up the cigarette pack and store it into the inventory, then he can examine the pack, open it and take the key.
In the moment the key is taken, the pack can be deleted from inventory and replaced by the taken key.
The pack is deleted just using the ReleaseItem GameMachine attached to the key itemTAG linked to the cigarette pack.
This GameMachine works by sending a RELEASE_ITEM message to the Player.
parentPrefab: the prefab