Difference between revisions of "TYPEDEF"

From SphereWiki
Jump to: navigation, search
m (Built-in Types: added details to t_armor)
(Built-in Types: Added some more built-in types: t_book, t_rune, t_booze, and t_potion)
Line 123: Line 123:
 
* LINK = UID of item to trigger
 
* LINK = UID of item to trigger
 
|-
 
|-
| ... || 19-22 || FIXME!!!
+
| t_book || 19 || This type is used for books of static or dynamic text.  It leverages the following properties:
 +
* MORE1L = This can be set to an ID of a book (some default book text is included in the sphere_books.scp file)
 +
* MORE1H = Some flags that determine book behavior:
 +
** 0c00: Scripted book
 +
** 0800: Editable book
 +
** 08000: ? time stamp ?
 +
* AUTHOR = The ID of the character that wrote the book
 +
* BODY.# = The text for each page of the book (starting with page 0)
 +
'''Note:''' we need more information on those flags...
 +
|-
 +
| t_rune || 20 || This type is used for recall runes.  It leverages the following properties:
 +
* MORE1 = The number of uses left before it wears out
 +
* MOREP = The coordinates of the marked location
 +
|-
 +
| t_booze || 21 || This type is used for alcohol (it causes a drunk effect when double clicked.)  It leverages the following properties:
 +
* TDATA1 = A flag that indicates whether the container is empty or not.
 +
|-
 +
| t_potion || 22 || This type is used for potions.  It leverages the following properties:
 +
* MORE1 = The potion spell effect that will result when the potion is double clicked
 +
* MORE2 = The strength of the potion (This has a different effect defending on the spell, usually between 0 and 1000)
 +
* MOREX = The countdown to explosion (for purple potions)
 +
* TDATA1 = A flag that indicates whether the container is empty or not
 
|-
 
|-
 
| 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:
 
| 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:

Revision as of 20:41, 4 November 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:


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 and t_container_locked 1 and 2 These types are used for containers. They leverage the following properties:
  • MORE1 = "ID" from the key that can unlock this item (If the MORE1 of the key matches the MORE1 of the container then they are linked)
  • MORE2 = The lock complexity (how hard it is to pick the lock)
  • MOREX = The trap type (not used yet?)
  • TDATA2 = The gumpID for the container (this is not a ITEMDEF)
  • TDATA3 = The minimum gump size
  • TDATA4 = The maximum gump size
  • LINK = UID of a secondary key?
t_door or t_door_unlocked 3 or 4 This type is used for both locked and unlocked doors. They leverage the following properties:
  • MORE1 = UID of this door's key (if it has one)
t_key 5 This type is used for keys. It leverages the following properties:
  • MORE1 = "ID" of the item(s) this key can unlock (if the MORE1 of the key matches the MORE1 of the container/door then they are linked)
  • LINK = If this is set to the UID of a "multi" object (like a house) the key can open all doors/containers in that multi?

Note: Keys, containers, and doors are interesting. If both a key and a door/container contain the same arbitrary MORE1 value, the key can be used to lock or unlock the door/container. That action changes the TYPE of the door/container to indicate whether it is locked or not. It also seems like LINK on the key can be set to the UID of a multi so that it can be used to open all doors/containers inside that multi.

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 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_food 8 This type is used for edible food. It leverages the following properties:
  • MORE1 = 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)
  • MOREZ = Is the poison level of the fruit
t_food_raw 9 This type is used for raw food. It leverages the following properties:
  • MORE1 = ID of the item it makes when cooked (i_unused if none)
t_armor 10 This type is used for armor. It leverages the following properties:
  • MORE1L = Max hitpoints
  • MORE1H = Current hitpoints
  • MOREX = Spell effect when worn (for example, setting MOREX=1 causes a permanent Clumsy effect)
  • MOREY = There are two possible effects of setting MOREY:
    1. If MOREX is set, then MOREY is the power/effect of that spell
    2. If the ATTR includes attr_magic, then there is an AR bonus (how is this calculated?)

Note: Old versions of sphere stored remaining charges in MORE2, this is no longer true.

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:
  • MORE1L = Max hitpoints
  • MORE1H = Current hitpoints
  • MOREY = Attack bonus (percentage), but only if ATTR & attr_magic

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 This type is used for macefighting weapons that have sharp cutting edges. It leverages the following properties:
  • MORE1L = Max hitpoints
  • MORE1H = Current hitpoints
  • MOREY = Attack bonus (percentage), but only if ATTR & attr_magic

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 This type is used for swordsmanship weapons. It leverages the following properties:
  • MORE1L = Max hitpoints
  • MORE1H = Current hitpoints
  • MOREY = Attack bonus (percentage), but only if ATTR & attr_magic

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 This type is used for fencing weapons. It leverages the following properties:
  • MORE1L = Max hitpoints
  • MORE1H = Current hitpoints
  • MOREY = Attack bonus (percentage), but only if ATTR & attr_magic

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 This type is used for archery weapons (bow or crossbow). It leverages the following properties:
  • MORE1L = Max hitpoints
  • MORE1H = Current hitpoints
  • MOREY = Attack bonus (percentage), but only if ATTR & attr_magic
  • 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:

  • 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 This type is used for magic wands. It leverages the following properties:
  • MORE1L = Max hitpoints
  • MORE1H = Current hitpoints
  • MORE2 = Max charges
  • MOREX = ID of the spell to cast when double-clicked
  • MOREY = Skill with which to cast the spell (100.0 = 1000)
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 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
t_book 19 This type is used for books of static or dynamic text. It leverages the following properties:
  • MORE1L = This can be set to an ID of a book (some default book text is included in the sphere_books.scp file)
  • MORE1H = Some flags that determine book behavior:
    • 0c00: Scripted book
    • 0800: Editable book
    • 08000: ? time stamp ?
  • AUTHOR = The ID of the character that wrote the book
  • BODY.# = The text for each page of the book (starting with page 0)

Note: we need more information on those flags...

t_rune 20 This type is used for recall runes. It leverages the following properties:
  • MORE1 = The number of uses left before it wears out
  • MOREP = The coordinates of the marked location
t_booze 21 This type is used for alcohol (it causes a drunk effect when double clicked.) It leverages the following properties:
  • TDATA1 = A flag that indicates whether the container is empty or not.
t_potion 22 This type is used for potions. It leverages the following properties:
  • MORE1 = The potion spell effect that will result when the potion is double clicked
  • MORE2 = The strength of the potion (This has a different effect defending on the spell, usually between 0 and 1000)
  • MOREX = The countdown to explosion (for purple potions)
  • TDATA1 = A flag that indicates whether the container is empty or not
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?
  • 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 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 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:
  • MOREP = The coordinates that the moongate leads to
... 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:
  • TDATA1 = ID of item created when the ore is smelted (usually ingots)
... 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-64 FIXME!!!
t_crops 65 This type is used to grow plants that likely bear fruit. Double clicking a t_crop item will harvest the fruit if it is ripe. It leverages the following properties:
  • MORE1 = Time in seconds before this item will grow to the next stage (this overrides the default server defined number)
  • TDATA1 = Is the ID of the first stage of the crop (the sprout)
  • TDATA2 = Is the ID of the next stage of the crop (or zero if this is the final mature crop which will bear the fruit)
  • TDATA3 = Is the ID of the fruit that this plant will grow and should only be set on the ripe plant

Note This type has unusual TIMER behavior in that regardless of the ATTR flags, the timer will restart when it reaches zero.

... 66-84 FIXME!!!
t_seed 84 This type is used for seeds. A seed can be created by using a dagger on a fruit (assuming the fruit is setup to have a seed.) A seed can be planted by double clicking it and targeting the ground (specifically t_dirt items). It leverages the following properties:
  • TDATA1 = The ID of a t_crop item that will grow the fruit that this seed comes from
... 85-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:
  • MORE1 = The ID of the item that will be created at the target location
... 116-128 FIXME!!!
t_fruit 129 This type is used for fruit. When double clicked, fruit will be eaten. Fruit can be grown from crops (t_crop). It leverages the following properties:
  • TDATA1 = The ID of a t_crop item that this fruit comes from (If not set, this fruit may not have a seed, use zero to be certain)
  • MOREM = Is the amount (0 to 127) of "food units" that will be gained when the item is used (eaten)
  • MOREZ = Is the poison level of the fruit
... 130-144 FIXME!!!
t_foliage 145 This type is very similar to t_crops, the difference being the foliage does not disappear when the fruit is harvested. It leverages the following properties:
  • MORE1 = Time in seconds before this item will grow to the next stage (this overrides the default server defined number)
  • TDATA1 = Is the ID of the first stage of the crop (the sprout)
  • TDATA2 = Is the ID of the next stage of the crop (or zero if this is the final mature crop which will bear the fruit)
  • TDATA3 = Is the ID of the fruit that this plant will grow and should only be set on the ripe plant

Note This type has unusual TIMER behavior in that regardless of the ATTR flags, the timer will restart when it reaches zero.

... 146-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