From The Mana World
(added script variables (former tmw_item_attributes))
(replaced customitem with item_instance)
Line 1: Line 1:
== Database ==
== Database ==
Layout for the SQL table to store customized equipment
Layout for the SQL table to store customized equipment
{{beginsqltable|tmw_customitem}}
{{beginsqltable|tmw_item_instances}}
{{sqltablerow | id | INTEGER | PRIMARY KEY | tmw_customitem_modifiers.id, tmw_customitem_runes.id | unique identifier}}
{{sqltablerow | id | INTEGER | PRIMARY KEY | tmw_item_instances_modifiers.id, tmw_item_instances_runes.id | unique identifier}}
{{sqltablerow | archetype-id | INTEGER | | | entry from items.xml to determine the slot the item is equipped in, the used sprite, item icon and description. In case of weapons it also affects the weapon category (used skill) and the attack zone.}}
{{sqltablerow | archetype-id | INTEGER | | | entry from items.xml to determine the slot the item is equipped in, the used sprite, item icon and description. In case of weapons it also affects the weapon category (used skill) and the attack zone.}}
{{sqltablerow | color | TEXT | | | colorization string}}
{{sqltablerow | color | TEXT | | | colorization string}}
Line 15: Line 15:


Stat modifiers during item creation. Also includes elemental modifiers.
Stat modifiers during item creation. Also includes elemental modifiers.
{{beginsqltable|tmw_customitem_modifiers}}
{{beginsqltable|tmw_item_instances_modifiers}}
{{sqltablerow | id | INTEGER | PRIMARY KEY |  | id of the custom item affected}}
{{sqltablerow | id | INTEGER | PRIMARY KEY |  | id of the custom item affected}}
{{sqltablerow | attribute | BYTE |  |  | affected character attribute or modified element}}
{{sqltablerow | attribute | BYTE |  |  | affected character attribute or modified element}}
Line 24: Line 24:


Spell runes engraved in the item.
Spell runes engraved in the item.
{{beginsqltable|tmw_customitem_runes}}
{{beginsqltable|tmw_item_instances_runes}}
{{sqltablerow | id | INTEGER | PRIMARY KEY |  | id of the custom item affected}}
{{sqltablerow | id | INTEGER | PRIMARY KEY |  | id of the custom item affected}}
{{sqltablerow | spell | INTEGER | | | spell of the rune }}
{{sqltablerow | spell | INTEGER | | | spell of the rune }}
Line 30: Line 30:


Custom variables for use in item scripts
Custom variables for use in item scripts
{{beginsqltable|tmw_customitem_vars}}
{{beginsqltable|tmw_item_instances_vars}}
{{sqltablerow | id | INTEGER | PRIMARY KEY |  | id of the custom item affected}}
{{sqltablerow | id | INTEGER | PRIMARY KEY |  | id of the custom item affected}}
{{sqltablerow | key | TEXT | | | key }}
{{sqltablerow | key | TEXT | | | key }}
Line 50: Line 50:
== Script API ==
== Script API ==


;tmw.create_custom_item(archetype-id, color, name, inscription, durability, initial-durability, weight, value, runeslots): Creates a custom item in the server database. Returns the ID of the item.
;tmw.create_item_instance(archetype-id, color, name, inscription, durability, initial-durability, weight, value, runeslots): Creates a custom item in the server database. Returns the ID of the item.
;tmw.change_custom_item(id, archetype-id, color, name, inscription, durability, initial-durability, weight, value, runeslots): Changes the values of a custom item in the server database. Every argument may be NULL to leave it as it is.
;tmw.change_item_instance(id, archetype-id, color, name, inscription, durability, initial-durability, weight, value, runeslots): Changes the values of a custom item in the server database. Every argument may be NULL to leave it as it is.
;tmw.add_modifier_to_item(id, attribute, absolute, multiplier, time): Adds a modifier to an item.
;tmw.add_modifier_to_item_instance(id, attribute, absolute, multiplier, time): Adds a modifier to an item.
;tmw.add_rune_to_item(id, spell): Adds a spell rune to an item.
;tmw.add_rune_to_item_instance(id, spell): Adds a spell rune to an item.
;tmw.get_custom_item(id): Returns a table with the attributes of the item.
;tmw.get_item_instance(id): Returns a table with the attributes of the item.
;tmw.get_custom_item_modifiers(id): Returns a table of tables with the modifier data of the item.
;tmw.get_item_instance_modifiers(id): Returns a table of tables with the modifier data of the item.
;tmw.get_custom_item_runes(id): Returns a table of tables with the rune data of the item.
;tmw.get_item_instance_runes(id): Returns a table of tables with the rune data of the item.
;tmw.get_custom_item_var(id, key): Returns the string stored in "key" in the var table of the item
;tmw.get_item_instance_var(id, key): Returns the string stored in "key" in the var table of the item
;tmw.set_custom_item_var(id, key, value): Sets the string stored in "key" in the var table of the item.
;tmw.set_item_instance_var(id, key, value): Sets the string stored in "key" in the var table of the item.




(function names not checked for consistency with the rest of the api)
(function names not checked for consistency with the rest of the api)

Revision as of 18:30, 7 May 2009

Database

Layout for the SQL table to store customized equipment

tmw_item_instances
Column name Datatype Nullable References Description
id INTEGER PRIMARY KEY tmw_item_instances_modifiers.id, tmw_item_instances_runes.id unique identifier
archetype-id INTEGER entry from items.xml to determine the slot the item is equipped in, the used sprite, item icon and description. In case of weapons it also affects the weapon category (used skill) and the attack zone.
color TEXT colorization string
name TEXT item name
inscription TEXT custom description which can be added by the crafting character
durability INTEGER remaining durability of the item
initial-durability INTEGER initial durability of the item
weight INTEGER weight
value INTEGER price NPCs pay for this item
rune-slots INTEGER number of slots for spell runes

Stat modifiers during item creation. Also includes elemental modifiers.

tmw_item_instances_modifiers
Column name Datatype Nullable References Description
id INTEGER PRIMARY KEY id of the custom item affected
attribute BYTE affected character attribute or modified element
absolute INTEGER linear attribute modifier
multiplier FLOAT attribute multiplier in case of character attribute. Elemental damage multiplier in case of element attribute.
time INTEGER time when the modifier wears off (for temporary enchantments)

Spell runes engraved in the item.

tmw_item_instances_runes
Column name Datatype Nullable References Description
id INTEGER PRIMARY KEY id of the custom item affected
spell INTEGER spell of the rune

Custom variables for use in item scripts

tmw_item_instances_vars
Column name Datatype Nullable References Description
id INTEGER PRIMARY KEY id of the custom item affected
key TEXT key
value TEXT value


Netcode

  • Item IDs are 32 bit unsigned integers
  • Item IDs 1 - 65.535 are non-customized generic items which may exist multiple times
  • Item IDs 65.536 - 4.294.967.296 are unique equipment items which may only exist once in the game.
  • When sending the inventory data to a character, every high id is followed by its archetype-id and colorization string. All other information about the item can be requested on demand with an additional message.
  • When sending look information about other characters the archetype-id and the colorisation are transfered
  • Colorisations are sent in a compressed format:
    • 1 Byte bitfield of the used colorisation channels. For each channel:
      • 1 Byte for number of entries in the color ramp. for every entry:
        • 3 Byte for red, green and blue component of color

Script API

tmw.create_item_instance(archetype-id, color, name, inscription, durability, initial-durability, weight, value, runeslots)
Creates a custom item in the server database. Returns the ID of the item.
tmw.change_item_instance(id, archetype-id, color, name, inscription, durability, initial-durability, weight, value, runeslots)
Changes the values of a custom item in the server database. Every argument may be NULL to leave it as it is.
tmw.add_modifier_to_item_instance(id, attribute, absolute, multiplier, time)
Adds a modifier to an item.
tmw.add_rune_to_item_instance(id, spell)
Adds a spell rune to an item.
tmw.get_item_instance(id)
Returns a table with the attributes of the item.
tmw.get_item_instance_modifiers(id)
Returns a table of tables with the modifier data of the item.
tmw.get_item_instance_runes(id)
Returns a table of tables with the rune data of the item.
tmw.get_item_instance_var(id, key)
Returns the string stored in "key" in the var table of the item
tmw.set_item_instance_var(id, key, value)
Sets the string stored in "key" in the var table of the item.


(function names not checked for consistency with the rest of the api)