Skip to main content

My First Item

In this tutorial you will learn how to create items in Daedalus - from swords, through potions, to food.

The C_Item Class - What Defines an Item?​

Every item in Gothic is an instance of the C_Item class. The most important fields are:

FieldTypeDescription
namestringName displayed in game
mainflagintMain category (weapon, armor, potion...)
flagsintDetailed type (sword, axe, bow...)
valueintValue in gold
visualstring3D model (*.3DS)
materialintMaterial (metal, wood, glass...)
damageTotalintTotal damage (weapons)
damagetypeintDamage type (edge, blunt...)
rangeintWeapon range
protection[]int[]Protection (armors)
cond_atr[]int[]Required attributes to use
cond_value[]int[]Required attribute values
on_state[]func[]Functions called on use
descriptionstringDescription in the inventory menu
TEXT[] / COUNT[]string[]/int[]Description lines in tooltip

Item Categories (mainflag)​

ConstantDescription
ITEM_KAT_NFMelee weapon
ITEM_KAT_FFRanged weapon
ITEM_KAT_ARMORArmor
ITEM_KAT_FOODFood
ITEM_KAT_POTIONSPotions
ITEM_KAT_DOCSDocuments
ITEM_KAT_RUNERunes and scrolls
ITEM_KAT_NONEOther (gold, keys, mission items)

Example 1: Melee Weapon (Sword)​

Create a file or add an instance to Items/IT_Melee_Weapons.d:

instance ItMw_Miecz_Konrada (C_Item)
{
name = "Konrad's Sword";

mainflag = ITEM_KAT_NF;
flags = ITEM_SWD;
material = MAT_METAL;

damageTotal = 35;
damagetype = DAM_EDGE;
range = 100;

cond_atr[2] = ATR_STRENGTH;
cond_value[2] = 20;

value = 250;

visual = "ItMw_025_1h_sld_sword_01.3DS";

description = name;
TEXT[2] = NAME_Dam_Edge; COUNT[2] = damageTotal;
TEXT[3] = NAME_Str_needed; COUNT[3] = cond_value[2];
TEXT[5] = NAME_Value; COUNT[5] = value;
};
FieldValueDescription
name"Konrad's Sword"Item name displayed in game
mainflagITEM_KAT_NFMelee weapon category
flagsITEM_SWDOne-handed sword
materialMAT_METALMetal (affects pickup/hit sound)
damageTotal3535 damage points
damagetypeDAM_EDGEEdge (slashing) damage
range100Attack range in units
cond_atr[2]ATR_STRENGTHRequires strength attribute
cond_value[2]20Minimum 20 strength to use
value250Worth 250 gold
visual"ItMw_025_1h_sld_sword_01.3DS"3D model file
descriptionnameTooltip header = item name
TEXT/COUNT-Tooltip lines shown in inventory
info

The flags field determines the weapon type: ITEM_SWD (1H sword), ITEM_AXE (1H axe), ITEM_2HD_SWD (2H sword), ITEM_2HD_AXE (2H axe).

Example 2: Potion​

instance ItPo_Zdrowie_Konrada (C_Item)
{
name = "Konrad's Health Potion";

mainflag = ITEM_KAT_POTIONS;
flags = ITEM_MULTI;

value = 75;
visual = "ItPo_Health_01.3ds";
material = MAT_GLAS;

on_state[0] = Use_ItPo_Zdrowie_Konrada;
scemeName = "POTIONFAST";
wear = WEAR_EFFECT;
effect = "SPELLFX_HEALTHPOTION";

description = name;
TEXT[1] = NAME_Bonus_HP; COUNT[1] = 100;
TEXT[5] = NAME_Value; COUNT[5] = value;
};

func void Use_ItPo_Zdrowie_Konrada ()
{
Npc_ChangeAttribute (self, ATR_HITPOINTS, 100);
};
FieldValueDescription
name"Konrad's Health Potion"Item name displayed in game
mainflagITEM_KAT_POTIONSPotion category
flagsITEM_MULTIStackable item
value75Worth 75 gold
visual"ItPo_Health_01.3ds"3D model file
materialMAT_GLASGlass (affects pickup sound)
on_state[0]Use_ItPo_Zdrowie_KonradaFunction called when item is used
scemeName"POTIONFAST"Drinking animation
wearWEAR_EFFECTEnables visual effect on use
effect"SPELLFX_HEALTHPOTION"Visual effect played on use
descriptionnameTooltip header = item name
TEXT[1]/COUNT[1]+100 HPTooltip: health bonus
TEXT[5]/COUNT[5]valueTooltip: item value
Npc_ChangeAttribute(self, ATR_HITPOINTS, 100)-Restores 100 HP on use
tip

ITEM_MULTI makes items of the same type stack in the inventory (instead of taking up separate slots).

Example 3: Food​

instance ItFo_Chleb_Konrada (C_Item)
{
name = "Konrad's Bread";
mainflag = ITEM_KAT_FOOD;
flags = ITEM_MULTI;
value = 10;
visual = "ItFo_Bread.3ds";
material = MAT_LEATHER;

on_state[0] = Use_ItFo_Chleb_Konrada;
scemeName = "FOOD";

description = name;
TEXT[1] = NAME_Bonus_HP; COUNT[1] = 15;
TEXT[5] = NAME_Value; COUNT[5] = value;
};

func void Use_ItFo_Chleb_Konrada ()
{
Npc_ChangeAttribute (self, ATR_HITPOINTS, 15);
};
FieldValueDescription
name"Konrad's Bread"Item name displayed in game
mainflagITEM_KAT_FOODFood category
flagsITEM_MULTIStackable item
value10Worth 10 gold
visual"ItFo_Bread.3ds"3D model file
materialMAT_LEATHERMaterial (affects sounds)
on_state[0]Use_ItFo_Chleb_KonradaFunction called on use
scemeName"FOOD"Eating animation
descriptionnameTooltip header = item name
TEXT[1]/COUNT[1]+15 HPTooltip: health bonus
TEXT[5]/COUNT[5]valueTooltip: item value
Npc_ChangeAttribute(self, ATR_HITPOINTS, 15)-Restores 15 HP on use

Giving Items to NPCs​

To have an NPC carry an item in their inventory, use in the NPC definition:

EquipItem (self, ItMw_Miecz_Konrada);
CreateInvItems (self, ItPo_Zdrowie_Konrada, 5);
CreateInvItems (self, ItFo_Chleb_Konrada, 3);
CreateInvItems (self, ItMi_Gold, 100);
CallDescription
EquipItem(self, ItMw_Miecz_Konrada)Equips the item (weapon/armor)
CreateInvItems(self, ItPo_Zdrowie_Konrada, 5)5 potions in backpack
CreateInvItems(self, ItFo_Chleb_Konrada, 3)3 bread loaves in backpack
CreateInvItems(self, ItMi_Gold, 100)100 gold
warning

EquipItem automatically equips the item (the NPC will hold the weapon or wear the armor). CreateInvItems only adds to the inventory.

Registration in Gothic.src​

Add the item files to Gothic.src - before NPC definitions:

Items\IT_Melee_Weapons.d
Items\IT_Potions.d
Items\IT_Food.d

Summary​

Creating items requires:

  1. An instance of the C_Item class with appropriate mainflag and flags
  2. Setting stats (damage, protection, requirements)
  3. Providing a 3D model (.3DS)
  4. For usable items - an on_state function that modifies attributes
  5. A tooltip (TEXT/COUNT) to display information in game
  6. Registration in Gothic.src