Scripting:Crafting

From 4Dimensions
Jump to: navigation, search

A player can craft an object by using ingredients, tools and subskills. The crafts are currently Metalworker, Leatherworker, Stoneworker, Textileworker, Woodworker, Brewing, Scribing and Cooking. The command professions shows the subskills available in the profession groups.

The object will be a unique item, different from the prototype, that will change with use. The differences are mostly stored in the object values 7 through 14:

   7. Colour
   8. Quality
   9. Material
   10. Dyecount
   11. Origin
   12. Stage
   13. Repairs
   14. Maximum Quality

Crafting is explained by treating each object value and describing the scripting commands that work on these values.


7. Colour

The colours are listed in the crafting section of oedit. The idea is that every colour has its own properties, which are up to the builder.


colour

   %obj.colour%

Returns the colour name.

   nop %obj.colour(red)%

Sets the colour of obj to 3 (red).


set_colour_name

   nop %obj.set_colour_name%

Adds or replaces a colour in the shortdesc of obj.

   %echo% %obj.shortdesc% 
   nop %obj.set_colour_name%
   %echo% %obj.shortdesc%

Possible results:

a sword
a black sword

a green car
a blue car

some grains
some orange grains


8. Quality

14. Maximum Quality

Quality and maximum quality are percentages reflecting how good an object is and how good it can be when it's repaired. When an object is created, the maximum quality should be set first, before setting the quality, because quality is forced to be less or equal to the maximum quality.


max_quality_value

   %object.max_quality_value%

Returns the max quality value of object.

   nop %obj.max_quality_value(80)%

Sets the max quality value of object to 80. If the quality is larger than the maximum, it's set to the maximum. The stats are updated as well.


quality_value

   %object.quality_value%

Returns the quality value of object.

   nop %obj.quality_value(80)%

Sets the quality value of object to 80. If the quality is larger than 80, it's set to 80. The stats are updated as well.


set_quality_name

   nop %object.set_quality_name%

Sets or replaces the quality name of object in the shortdesc, depending on the quality value.


save_affects

   nop %object.save_affects%

Sets the original stats of object to the current stats. This should be called if the object has stats and when it's at the maximum quality. Negative stats (e.g. -3 wis or +5 AC) are permanent, the others can be lost if the object loses quality, and gained when it's repaired. If the stats are +1 wis, -1 AC, -3 str then the object has 2 positive stats. One stat is lost when the quality drops below 2/3 and the remaining stat is gone once the quality reaches 1/3 of the maximum. A repair to the maximum quality recovers all lost stats.


9. Material

Every object is made out of a certain material, which belong to a material group. The material groups are: base-material, metal, stone, organic, textile, wood, and other. The materials are listed in the crafting section of oedit.


material

   %object.material%

Returns the name of the material object is made of.

   nop %object.material(plastic)

Sets the material of object to plastic.


in_material_group

   %object.in_material_group(organic)%

Returns 1 if object is made of a material from the group organic.


10. Dyecount

Dyeing gives an object colour. To add a bit of risk to dyeing, the dyecount is saved so you can check if an object should turn black forever for example.


dyecount

   %object.dyecount%

Returns the number of times object has been dyed.

   nop %object.dyecount(3)%

Sets the dyecount of object to 3.


11. Origin

The origin of an object may determine the quality of the end product, or what you can do with it. The origins are listed in the crafting section of oedit. Currently, there are origins for trees and animals. When a tree is lumberjacked, the log gets the origin of the tree. Similarly, the skin from a corpse automatically gets the origin of the animal.


origin

   %object.origin%

Returns the origin name of object.


12. Stage

To make sure the end product is always made in the same order, the work can be divided into stages. At each step the activity can be matched with the stage.


stage_value

   %object.stage_value%

Returns the stage value of object.

   %object.stage_value(2)%

Sets the stage value of object to 2.


13. Repairs

An object can be repaired, which raises the quality and returns some or all of the original stats. When the maximum quality becomes zero, the object reverts to being a normal object and can no longer be repaired.


num_of_repairs

   %object.num_of_repairs%

Returns the number of times object has been repaired.


repair

   %object.repair(70)%

Sets the max quality of object to 70, or to the original max quality if it's smaller than 70. The quality is set to the maximum quality. The number of repairs is increased by one and the affects are updated.


save_affects

   nop %object.save_affects%

Sets the original stats of object to the current stats. This should be called if the object has stats and when it's at the maximum quality. Negative stats (e.g. -3 wis or +5 AC) are permanent, the others can be lost if the object loses quality, and gained when it's repaired. If the stats are +2 wis, -2 AC, -1 str then the object has four positive stats. One stat is lost if the object quality drops below 80%. A second stat is lost if it drops below 60%, and all stats are gone if the quality is below 20%. A repair may recover all lost stats.