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...)) |
|||
Line 7: | Line 7: | ||
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|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. | 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|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. | ||
+ | |||
+ | {| border="1" | ||
+ | ! DEFNAME !! Number !! Description | ||
+ | |- | ||
+ | | t_normal || 0 || No built-in behavior. | ||
+ | |- | ||
+ | | t_container || 1 || MORE = UID of this container's key if it has one<br> | ||
+ | LINK = UID of the key also | ||
+ | |- | ||
+ | | t_container_locked || 2 || MORE = UID of this container's key<br> | ||
+ | LINK=UID of the key<sup>1</sup> | ||
+ | |- | ||
+ | | 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<br> | ||
+ | LINK = Usually the UID of a multi (house), etc, but can also be the UID of a door<br> | ||
+ | '''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. | ||
+ | |- | ||
+ | | t_light_lit || 6 || MOREY = number of charges before it disappears<br> | ||
+ | MOREZ = type of light sphere | ||
+ | |- | ||
+ | | t_light_out || 7 || MOREY = number of charges before it disappears<br> | ||
+ | MOREZ = type of light sphere | ||
+ | |- | ||
+ | | t_food || 8 || MORE = ID of the item it makes when cooked (i_unused if none)<br> | ||
+ | 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<br> | ||
+ | MORE1H = current hitpoints<br> | ||
+ | MOREY = armor bonus (percentage) if ATTR & attr_magic | ||
+ | |- | ||
+ | | t_weapon_mace_smith || 11 || MORE1L = max hitpoints<br> | ||
+ | MORE1H = current hitpoints<br> | ||
+ | MOREY = attack bonus (percentage) if ATTR & attr_magic<br> | ||
+ | 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.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. | ||
+ | |- | ||
+ | | t_weapon_mace_sharp || 12 || MORE1L = max hitpoints<br> | ||
+ | MORE1H = current hitpoints<br> | ||
+ | MOREY = attack bonus (percentage) if ATTR & attr_magic<br> | ||
+ | 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.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. | ||
+ | |- | ||
+ | | t_weapon_sword || 13 || MORE1L = max hitpoints<br> | ||
+ | MORE1H = current hitpoints<br> | ||
+ | MOREY = attack bonus (percentage) if ATTR & attr_magic<br> | ||
+ | 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.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. | ||
+ | |- | ||
+ | | t_weapon_fence || 14 || MORE1L = max hitpoints<br> | ||
+ | MORE1H = current hitpoints<br> | ||
+ | MOREY = attack bonus (percentage) if ATTR & attr_magic<br> | ||
+ | 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.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. | ||
+ | |- | ||
+ | | t_weapon_bow || 15 || MORE1L = max hitpoints<br> | ||
+ | MORE1H = current hitpoints<br> | ||
+ | MOREY = attack bonus (percentage) if ATTR & attr_magic<br> | ||
+ | TDATA3 = ID of arrow item (what does it consume on a shot?)<br> | ||
+ | TDATA4 = ID of the arrow animation (usually i_arrow_x)<br> | ||
+ | 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.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.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.AMMOANIMHUE = to override the color of the ammo animation this item uses. | ||
+ | |- | ||
+ | | t_wand || 16 || MORE1L = max hitpoints<br> | ||
+ | MORE1H = current hitpoints<br> | ||
+ | MORE2 = max charges<br> | ||
+ | MOREX = spell to cast when double-clicked<br> | ||
+ | MOREY = skill with which to cast the spell (100.0 = 1000) | ||
+ | |- | ||
+ | | 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<br> | ||
+ | (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<br> | ||
+ | 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<br> | ||
+ | TDATA1 = ID of item created when the ore is smelted (usually an ingot) | ||
+ | |- | ||
+ | | ... | ||
+ | |- | ||
+ | | t_tree || 44 || Can be chopped for wood<br> | ||
+ | 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== | ||
+ | |||
+ | {| border="1" | ||
+ | ! DEFNAME !! File !! Description | ||
+ | |- | ||
+ | | t_advance_gate || ??.scp || MORE = ID of character to change into | ||
+ | |} | ||
==Syntax== | ==Syntax== |
Revision as of 00:49, 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 | 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