Difference between revisions of "TYPEDEF"
(Added a table of built-in itemdefs and some of their basic properties (moved from Taran's chapter 3 article...)) |
m (→Built-in Types: Syntax cleanup) |
||
Line 16: | Line 16: | ||
| t_normal || 0 || No built-in behavior. | | t_normal || 0 || No built-in behavior. | ||
|- | |- | ||
− | | t_container || 1 || MORE = UID of this container's key if it has one | + | | t_container || 1 || This type is used for unlocked containers. It leverages the following properties: |
− | LINK = UID of | + | * MORE = UID of this container's key (if it has one) |
+ | * LINK = UID of a secondary key (see t_key for an explanation of this curious fact) | ||
|- | |- | ||
− | | t_container_locked || 2 || MORE = UID of this container's key | + | | t_container_locked || 2 || This type is used for ''locked'' containers. It leverages the following properties: |
− | LINK=UID of | + | * MORE = UID of this container's key |
+ | * LINK = UID of a secondary key (see t_key for an explanation of this curious fact) | ||
|- | |- | ||
− | | t_door || 3 || MORE = UID of | + | | t_door || 3 || This type is used for unlocked doors. It leverages the following properties: |
+ | * MORE = UID of this door's key (if it has one) | ||
|- | |- | ||
− | | t_door_locked || 4 || MORE = UID of | + | | t_door_locked || 4 || This type is used for ''locked'' doors. It leverages the following properties: |
+ | * MORE = UID of this door's key | ||
|- | |- | ||
− | | t_key || 5 || MORE = UID of the item this key can unlock | + | | t_key || 5 || This type is used for keys. It leverages the following properties: |
− | LINK = Usually the UID of a multi (house), etc, but can also be the UID of a door | + | * MORE = UID of the item this key can unlock |
− | '''Note:''' Keys and doors are very odd. If both a key and a door contain the same multi UID in either MORE or LINK, the key will open the door. This is how there can be multiple doors in one house using a single key. You can also have different UIDs stored in MORE and LINK so a single key will open more than one door. | + | * LINK = Usually the UID of a multi (house), etc, but can also be the UID of a door |
− | |- | + | '''Note:''' Keys, containers, and doors are very odd. If both a key and a door contain the same multi UID in either MORE or LINK, the key will open the door. This is how there can be multiple doors in one house using a single key. You can also have different UIDs stored in MORE and LINK so a single key will open more than one door. |
− | | t_light_lit || 6 || MOREY = | + | |- |
− | MOREZ = | + | | t_light_lit || 6 || This type is used for light sources that can be turned on or off. It leverages the following properties: |
+ | * MOREY = Number of charges before the item is consumed | ||
+ | * MOREZ = Type of light pattern it will cast | ||
|- | |- | ||
− | | t_light_out || 7 || MOREY = | + | | t_light_out || 7 || This type is used for light sources that can be turned on or off. It leverages the following properties: |
− | MOREZ = | + | * MOREY = Number of charges before the item is consumed |
+ | * MOREZ = Type of light pattern it will cast | ||
|- | |- | ||
− | | t_food || 8 || MORE = ID of the item it makes when cooked (i_unused if none) | + | | t_food || 8 || This type is used for edible food. It leverages the following properties: |
− | MOREM = Is the amount (0 to 127) of "food units" that will be gained when the item is used | + | * 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 (eaten) | ||
|- | |- | ||
− | | t_food_raw || 9 || MORE = ID of the item it makes when cooked (i_unused if none) | + | | t_food_raw || 9 || This type is used for ''raw'' food. It leverages the following properties: |
+ | * MORE = ID of the item it makes when cooked (i_unused if none) | ||
|- | |- | ||
− | | t_armor || 10 || MORE1L = | + | | t_armor || 10 || This type is used for armor. It leverages the following properties: |
− | MORE1H = | + | * MORE1L = Max hitpoints |
− | MOREY = | + | * MORE1H = Current hitpoints |
+ | * MOREY = Armor bonus (percentage), but only if ATTR & attr_magic | ||
|- | |- | ||
− | | t_weapon_mace_smith || 11 || MORE1L = | + | | t_weapon_mace_smith || 11 || This type is used for macefighting weapons that can also be used by blacksmiths to forge items. It leverages the following properties: |
− | MORE1H = | + | * MORE1L = Max hitpoints |
− | MOREY = | + | * MORE1H = Current hitpoints |
+ | * MOREY = Attack bonus (percentage), but only if ATTR & attr_magic | ||
The following overrides can be set on a per item basis: | The following overrides can be set on a per item basis: | ||
− | * TAG.OVERRIDE.DAMAGETYPE = can be used on a per item basis to override the types of damage this weapon does | + | * TAG.OVERRIDE.DAMAGETYPE = can be used on a per item basis to override the types of damage this weapon does |
− | * TAG.OVERRIDE.SOUND_HIT = can be used on a per item basis to override the sound this weapon makes when it hits | + | * TAG.OVERRIDE.SOUND_HIT = can be used on a per item basis to override the sound this weapon makes when it hits |
− | * TAG.OVERRIDE.SOUND_MISS = can be used on a per item basis to override the sound this weapon makes when it misses | + | * TAG.OVERRIDE.SOUND_MISS = can be used on a per item basis to override the sound this weapon makes when it misses |
|- | |- | ||
− | | t_weapon_mace_sharp || 12 || MORE1L = | + | | t_weapon_mace_sharp || 12 || This type is used for macefighting weapons that have sharp cutting edges. It leverages the following properties: |
− | MORE1H = | + | * MORE1L = Max hitpoints |
− | MOREY = | + | * MORE1H = Current hitpoints |
+ | * MOREY = Attack bonus (percentage), but only if ATTR & attr_magic | ||
The following overrides can be set on a per item basis: | The following overrides can be set on a per item basis: | ||
− | * TAG.OVERRIDE.DAMAGETYPE = can be used on a per item basis to override the types of damage this weapon does | + | * TAG.OVERRIDE.DAMAGETYPE = can be used on a per item basis to override the types of damage this weapon does |
− | * TAG.OVERRIDE.SOUND_HIT = can be used on a per item basis to override the sound this weapon makes when it hits | + | * TAG.OVERRIDE.SOUND_HIT = can be used on a per item basis to override the sound this weapon makes when it hits |
− | * TAG.OVERRIDE.SOUND_MISS = can be used on a per item basis to override the sound this weapon makes when it misses | + | * TAG.OVERRIDE.SOUND_MISS = can be used on a per item basis to override the sound this weapon makes when it misses |
|- | |- | ||
− | | t_weapon_sword || 13 || MORE1L = | + | | t_weapon_sword || 13 || This type is used for swordsmanship weapons. It leverages the following properties: |
− | MORE1H = | + | * MORE1L = Max hitpoints |
− | MOREY = | + | * MORE1H = Current hitpoints |
+ | * MOREY = Attack bonus (percentage), but only if ATTR & attr_magic | ||
The following overrides can be set on a per item basis: | The following overrides can be set on a per item basis: | ||
− | * TAG.OVERRIDE.DAMAGETYPE = can be used on a per item basis to override the types of damage this weapon does | + | * TAG.OVERRIDE.DAMAGETYPE = can be used on a per item basis to override the types of damage this weapon does |
− | * TAG.OVERRIDE.SOUND_HIT = can be used on a per item basis to override the sound this weapon makes when it hits | + | * TAG.OVERRIDE.SOUND_HIT = can be used on a per item basis to override the sound this weapon makes when it hits |
− | * TAG.OVERRIDE.SOUND_MISS = can be used on a per item basis to override the sound this weapon makes when it misses | + | * TAG.OVERRIDE.SOUND_MISS = can be used on a per item basis to override the sound this weapon makes when it misses |
|- | |- | ||
− | | t_weapon_fence || 14 || MORE1L = | + | | t_weapon_fence || 14 || This type is used for fencing weapons. It leverages the following properties: |
− | MORE1H = | + | * MORE1L = Max hitpoints |
− | MOREY = | + | * MORE1H = Current hitpoints |
+ | * MOREY = Attack bonus (percentage), but only if ATTR & attr_magic | ||
The following overrides can be set on a per item basis: | The following overrides can be set on a per item basis: | ||
− | * TAG.OVERRIDE.DAMAGETYPE = can be used on a per item basis to override the types of damage this weapon does | + | * TAG.OVERRIDE.DAMAGETYPE = can be used on a per item basis to override the types of damage this weapon does |
− | * TAG.OVERRIDE.SOUND_HIT = can be used on a per item basis to override the sound this weapon makes when it hits | + | * TAG.OVERRIDE.SOUND_HIT = can be used on a per item basis to override the sound this weapon makes when it hits |
− | * TAG.OVERRIDE.SOUND_MISS = can be used on a per item basis to override the sound this weapon makes when it misses | + | * TAG.OVERRIDE.SOUND_MISS = can be used on a per item basis to override the sound this weapon makes when it misses |
|- | |- | ||
− | | t_weapon_bow || 15 || MORE1L = | + | | t_weapon_bow || 15 || This type is used for archery weapons (bow or crossbow). It leverages the following properties: |
− | MORE1H = | + | * MORE1L = Max hitpoints |
− | MOREY = | + | * MORE1H = Current hitpoints |
− | TDATA3 = ID of arrow item ( | + | * MOREY = Attack bonus (percentage), but only if ATTR & attr_magic |
− | TDATA4 = ID of the arrow animation (usually i_arrow_x) | + | * TDATA3 = ID of arrow item that will be fired (and must therefore be on the player's person) |
+ | * TDATA4 = ID of the arrow animation (for bows it is usually i_arrow_x, for crossbows, i_xbow_x) | ||
The following overrides can be set on a per item basis: | The following overrides can be set on a per item basis: | ||
− | * TAG.OVERRIDE.DAMAGETYPE = to override the types of damage this weapon does | + | * TAG.OVERRIDE.DAMAGETYPE = to override the types of damage this weapon does |
− | * TAG.OVERRIDE.SOUND_HIT = to override the sound this weapon makes when it hits | + | * TAG.OVERRIDE.SOUND_HIT = to override the sound this weapon makes when it hits |
− | * TAG.OVERRIDE.SOUND_MISS = to override the sound this weapon makes when it misses | + | * TAG.OVERRIDE.SOUND_MISS = to override the sound this weapon makes when it misses |
− | * TAG.OVERRIDE.AMMOTYPE = to override the type of ammo (TDATA3) this item uses | + | * TAG.OVERRIDE.AMMOTYPE = to override the type of ammo (TDATA3) this item uses |
− | * TAG.OVERRIDE.AMMOANIM = to override the ammo animation (TDATA4) this item uses | + | * TAG.OVERRIDE.AMMOANIM = to override the ammo animation (TDATA4) this item uses |
− | * TAG.OVERRIDE.AMMOANIMHUE = to override the color of the ammo animation this item uses | + | * TAG.OVERRIDE.AMMOANIMHUE = to override the color of the ammo animation this item uses |
|- | |- | ||
− | | t_wand || 16 || MORE1L = | + | | t_wand || 16 || This type is used for magic wands. It leverages the following properties: |
− | MORE1H = | + | * MORE1L = Max hitpoints |
− | MORE2 = | + | * MORE1H = Current hitpoints |
− | MOREX = spell to cast when double-clicked | + | * MORE2 = Max charges |
− | MOREY = | + | * MOREX = ID of the spell to cast when double-clicked |
+ | * MOREY = Skill with which to cast the spell (100.0 = 1000) | ||
|- | |- | ||
− | | t_telepad || 17 || MOREP = | + | | t_telepad || 17 || This type is used for teleportation pads. It leverages the following properties: |
+ | * MOREP = Coordinates of the point to which you will teleport when you step on the item | ||
+ | * MORE1 = The animation that will be shown to anyone witnessing the teleport? | ||
+ | * MORE2 = ? | ||
|- | |- | ||
− | | t_switch || 18 || LINK = UID of item to trigger | + | | t_switch || 18 || This type is used for switches. The way these things work is, when used, they trigger @DCLICK on the LINK object. It leverages the following properties: |
− | + | * LINK = UID of item to trigger | |
|- | |- | ||
− | | ... | + | | ... || 19-22 || FIXME!!! |
|- | |- | ||
− | | t_fire || 23 || | + | | t_fire || 23 || This type is used for fires (and ovens?). These items can be used to cook food, and they can burn you if stepped on. It leverages the following properties: |
− | TIMER = time until it decays | + | * TIMER = time until it decays? |
+ | * MORE1 (or MORE2?) = Amount of damage it will cause when stepped on or dclicked | ||
+ | * MOREZ = Type of light pattern it will cast | ||
|- | |- | ||
− | | ... | + | | ... || 24-31 || FIXME!!! |
|- | |- | ||
− | | t_scroll || 32 || MOREX = spell to cast when double-clicked | + | | t_scroll || 32 || This type is used for scrolls. It leverages the following properties: |
+ | * MOREX = ID of the spell to cast when double-clicked | ||
+ | * MOREY = Power of the spell (equivalent to the EFFECT setting of the spell itself?) | ||
|- | |- | ||
− | | ... | + | | ... || 33-37 || FIXME!!! |
|- | |- | ||
− | | t_shrine || 38 || Will resurrect a ghost when double-clicked | + | | t_shrine || 38 || This type is used for shrines. Will resurrect a ghost when double-clicked by a ghost. |
|- | |- | ||
− | | t_moongate || 39 || MOREP = The coordinates that the moongate leads to | + | | t_moongate || 39 || This type is used for moongates. When stepped on they teleport the player to another location. It leverages the following properties: |
+ | * MOREP = The coordinates that the moongate leads to | ||
|- | |- | ||
− | | ... | + | | ... || 40-41 || FIXME!!! |
|- | |- | ||
− | | t_ore || 42 || | + | | t_ore || 42 || This type is harvested by miners, and converted by blacksmiths (using a forge) into something else. It leverages the following properties: |
− | TDATA1 = ID of item created when the ore is smelted (usually | + | * TDATA1 = ID of item created when the ore is smelted (usually ingots) |
|- | |- | ||
− | | ... | + | | ... || 43 || FIXME!!! |
|- | |- | ||
− | | t_tree || 44 || | + | | t_tree || 44 || This type is chopped by lumberjacks to get logs. It leverages the following properties: |
− | FRUIT = item gathered if double-clicked | + | FRUIT = ID of item gathered if double-clicked (usually logs) |
|- | |- | ||
− | | ... | + | | ... || 45-114 || FIXME!!! |
|- | |- | ||
− | | t_deed || 115 || | + | | t_deed || 115 || This type is used to create something else when double clicked. It is perhaps the best solution for a player to place a ''multi'' part item like a house. When double clicked, it will prompt for a target location. It leverages the following properties: |
+ | * MORE = The ID of the item that will be created at the target location. | ||
|- | |- | ||
− | | ... | + | | ... || 116-175 || FIXME!!! |
|- | |- | ||
− | | t_eq_script || 176 || This | + | | t_eq_script || 176 || This type can have tags and can be equipped. Possibly used for memory objects that leverage @Equip and @UnEquip triggers. |
|- | |- | ||
− | | ... | + | | ... || 177-182 || FIXME!!! |
|- | |- | ||
− | | t_script || 183 || This | + | | t_script || 183 || This type can have tags, but can NOT be equipped. |
|} | |} | ||
Revision as of 02:24, 20 October 2010
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 | This type is used for unlocked containers. It leverages the following properties:
|
t_container_locked | 2 | This type is used for locked containers. It leverages the following properties:
|
t_door | 3 | This type is used for unlocked doors. It leverages the following properties:
|
t_door_locked | 4 | This type is used for locked doors. It leverages the following properties:
|
t_key | 5 | This type is used for keys. It leverages the following properties:
Note: Keys, containers, and doors are very odd. If both a key and a door contain the same multi UID in either MORE or LINK, the key will open the door. This is how there can be multiple doors in one house using a single key. You can also have different UIDs stored in MORE and LINK so a single key will open more than one door. |
t_light_lit | 6 | This type is used for light sources that can be turned on or off. It leverages the following properties:
|
t_light_out | 7 | This type is used for light sources that can be turned on or off. It leverages the following properties:
|
t_food | 8 | This type is used for edible food. It leverages the following properties:
|
t_food_raw | 9 | This type is used for raw food. It leverages the following properties:
|
t_armor | 10 | This type is used for armor. It leverages the following properties:
|
t_weapon_mace_smith | 11 | This type is used for macefighting weapons that can also be used by blacksmiths to forge items. It leverages the following properties:
The following overrides can be set on a per item basis:
|
t_weapon_mace_sharp | 12 | This type is used for macefighting weapons that have sharp cutting edges. It leverages the following properties:
The following overrides can be set on a per item basis:
|
t_weapon_sword | 13 | This type is used for swordsmanship weapons. It leverages the following properties:
The following overrides can be set on a per item basis:
|
t_weapon_fence | 14 | This type is used for fencing weapons. It leverages the following properties:
The following overrides can be set on a per item basis:
|
t_weapon_bow | 15 | This type is used for archery weapons (bow or crossbow). It leverages the following properties:
The following overrides can be set on a per item basis:
|
t_wand | 16 | This type is used for magic wands. It leverages the following properties:
|
t_telepad | 17 | This type is used for teleportation pads. It leverages the following properties:
|
t_switch | 18 | This type is used for switches. The way these things work is, when used, they trigger @DCLICK on the LINK object. It leverages the following properties:
|
... | 19-22 | FIXME!!! |
t_fire | 23 | This type is used for fires (and ovens?). These items can be used to cook food, and they can burn you if stepped on. It leverages the following properties:
|
... | 24-31 | FIXME!!! |
t_scroll | 32 | This type is used for scrolls. It leverages the following properties:
|
... | 33-37 | FIXME!!! |
t_shrine | 38 | This type is used for shrines. Will resurrect a ghost when double-clicked by a ghost. |
t_moongate | 39 | This type is used for moongates. When stepped on they teleport the player to another location. It leverages the following properties:
|
... | 40-41 | FIXME!!! |
t_ore | 42 | This type is harvested by miners, and converted by blacksmiths (using a forge) into something else. It leverages the following properties:
|
... | 43 | FIXME!!! |
t_tree | 44 | This type is chopped by lumberjacks to get logs. It leverages the following properties:
FRUIT = ID of item gathered if double-clicked (usually logs) |
... | 45-114 | FIXME!!! |
t_deed | 115 | This type is used to create something else when double clicked. It is perhaps the best solution for a player to place a multi part item like a house. When double clicked, it will prompt for a target location. It leverages the following properties:
|
... | 116-175 | FIXME!!! |
t_eq_script | 176 | This type can have tags and can be equipped. Possibly used for memory objects that leverage @Equip and @UnEquip triggers. |
... | 177-182 | FIXME!!! |
t_script | 183 | This type can have tags, but can NOT be equipped. |
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