TYPEDEF
Type definitions are the equivalent of EVENTS that can be attached to items. There are different properties that can be used to attach a type block to an item or set of items:
- item definitions via their TYPE and/or TEVENTS property.
- items via their TYPE and/or EVENTS property.
In addition to handling triggers, type definitions can also be used to define different types of terrain. This can be used to affect the return value of the TYPE property on map points, or for some hardcoded types such as t_rock it can be used to define which terrain IDs Sphere should consider to be rock when the mining skill is used.
Built-in Types
The built-in types are all listed in the sphere_defs.scp file. The table below only lists some of the built-in types and it is VERY weak on actual details...so use with care.
DEFNAME | Number | Description |
---|---|---|
t_normal | 0 | No built-in behavior. |
t_container | 1 | MORE = UID of this container's key if it has one LINK = UID of the key also |
t_container_locked | 2 | MORE = UID of this container's key LINK=UID of the key1 |
t_door | 3 | MORE = UID of the key |
t_door_locked | 4 | MORE = UID of the key |
t_key | 5 | MORE = UID of the item this key can unlock LINK = Usually the UID of a multi (house), etc, but can also be the UID of a door |
t_light_lit | 6 | MOREY = number of charges before it disappears MOREZ = type of light sphere |
t_light_out | 7 | MOREY = number of charges before it disappears MOREZ = type of light sphere |
t_food | 8 | MORE = ID of the item it makes when cooked (i_unused if none) MOREM = Is the amount (0 to 127) of "food units" that will be gained when the item is used. |
t_food_raw | 9 | MORE = ID of the item it makes when cooked (i_unused if none) |
t_armor | 10 | MORE1L = max hitpoints MORE1H = current hitpoints |
t_weapon_mace_smith | 11 | MORE1L = max hitpoints MORE1H = current hitpoints
|
t_weapon_mace_sharp | 12 | MORE1L = max hitpoints MORE1H = current hitpoints
|
t_weapon_sword | 13 | MORE1L = max hitpoints MORE1H = current hitpoints
|
t_weapon_fence | 14 | MORE1L = max hitpoints MORE1H = current hitpoints
|
t_weapon_bow | 15 | MORE1L = max hitpoints MORE1H = current hitpoints
|
t_wand | 16 | MORE1L = max hitpoints MORE1H = current hitpoints |
t_telepad | 17 | MOREP = coordinates of the point to which you will teleport when you step on the item |
t_switch | 18 | LINK = UID of item to trigger (When you double-click the switch item, it will also pretend like you double-clicked the LINK item. If you link it to a door, it will open the door.) |
... | ||
t_fire | 23 | Will burn you when stepped on TIMER = time until it decays |
... | ||
t_scroll | 32 | MOREX = spell to cast when double-clicked |
... | ||
t_shrine | 38 | Will resurrect a ghost when double-clicked |
t_moongate | 39 | MOREP = The coordinates that the moongate leads to |
... | ||
t_ore | 42 | Can be smelted on a forge into something else TDATA1 = ID of item created when the ore is smelted (usually an ingot) |
... | ||
t_tree | 44 | Can be chopped for wood FRUIT = item gathered if double-clicked |
... | ||
t_deed | 115 | sphereitem_multis.scp |
... | ||
t_eq_script | 176 | This item can have tags and is equippable. Possibly used for memory objects that leverage @Equip and @UnEquip triggers. |
... | ||
t_script | 183 | This item can have tags, but is NOT equippable. |
Scripted TYPEDEFs
DEFNAME | File | Description |
---|---|---|
t_advance_gate | ??.scp | MORE = ID of character to change into |
Syntax
The syntax for defining a type is:
[TYPEDEF defname]
TERRAIN=id
TERRAIN=start_id, end_id
ON=trigger_name
script
ON=trigger_name
script
Any number of triggers can be handled by one TYPEDEF definition, however it is not possible to handle the same trigger twice without using multiple definitions.
The trigger name can be the name of any item trigger. The return value from the script can affect Sphere's hardcoded behaviour in different ways. See the documentation for the trigger to discover what parameters are passed in to each trigger and what the return values do.
Note: If the defname matches any of Sphere's hardcoded types (see 'typedefs' block in sphere_defs.scp), then the TYPEDEF can be used to override the behaviours of items of that type.
Examples
// // Water definition from default script pack. // [TYPEDEF t_water] TERRAIN = 0a8 0ab TERRAIN = 0136 0137
// // Makes an item speak when double clicked. // [TYPEDEF t_exampletype] ON=@DClick SAY I have been double clicked! RETURN 2