Items and Loot
Simple Item Creation
Now that we have wolves wandering around Zone One, it is time to create an item to add to their loot table that we set up in the NPC and Monster Tutorial.
1. Load the Torque MMO Kit IDE and open the file ~\test.game\genesis\zone\zoneone\items.py.
2. First, we are going to assign a new item variable and name the item, Wolf Fang.
#--- Wolf Fang item = DBItemProto(name="Wolf Fang")
3. Next, we'll assign a description and an image to the item:
item.desc = "This is a very sharp fang!" item.bitmap = "STUFF/1"
**************Add a fang bitmap to test.game************
Note: The minimum that every item requires is a name and a bitmap. The item description is viewed when a character investigates the item by right-clicking on it. Bitmaps are located here: ~\test.game\data\ui\items in either the EQUIPMENT or STUFF folders.
For a complete list of all parameters that can be assigned to an item, see ~\mud\world\item.py.
4. Now let's add this back to the loot tables of Radothe and the Wild Wolf spawns. Open ~\test.game\genesis\zone\zoneone\spawns.py. Locate the Wolf Fang in Radothe's and the Wild Wolf's spawn and remove the pound sign (#).
5. Save the file, select World -> Compile World and verify that there are no errors in the message window.
6. From inside the Torque MMO Kit IDE select World -> Edit Zone and load zoneone. Using the immortal command, select a wolf spawn, and type /imm kill to kill the wolf, then loot the corpse by double-clicking. Repeat this until a wolf drops one of its fangs. Verify the item's image and description are set up properly by right-clicking on the item in your inventory window. Type /camp to exit the game.
7. This is going to be a quest item and the player is going to need to retrieve several of them. So we need to add some additional parameters.
Inventory space is very valuable so we will allow players to stack multiples of this item. We'll set the stackMax to 10 and the stackDefault to 1. Stack default refers to the number of this item that are dropped off a corpse at a time, i.e. each time a wolf drops this item it will only be in a stack of 1.
item.stackMax = 10 item.stackDefault = 1
Now, since this is a quest item, we don't want players to be able to trade with one another and avoid doing this vital step of the quest, so we'll add the following flag to it.
item.flags = RPG_ITEM_SOULBOUND
8. Save the file, select World -> Compile World and verify that there are no errors in the message window.
Intermediate Item Creation - Armor
Guard Andarry is patrolling the borders of Zone One and should be given a proper uniform worthy of his stature. To make a complete outfit, we need to create pieces for ARMS, BODY, FEET, HANDS, and LEGS. (We'll create a weapon for him later.)
1. Since these items will only be found on guards in Zone One we'll save them in the following file: ~\test.game\genesis\zone\zoneone\items.py. We'll start by assigning a new item variable and calling it “Andarrian Sleeves”.
#--- Andarrian Sleeves item = DBItemProto() item.name = "Andarrian Sleeves"
Setup the type next. We want to list this item as armor and non-sellable by vendors so we use the 'Unique' tag:
item.itemType = ['UNIQUE','ARMOR']
Now, we want to restrict who can wear this item by skill and level:
item.skill="Medium Armor" item.level = 20
Let's flag this item to further limit its use as well as define it. The artifact flag means that no variables can alter the base piece. The premium flag means that only players who have purchased the game can use this piece (all items over item.level of 50 automatically are assigned this flag). The soulbound flag means that players cannot trade this item. The indestructible flag means that this item never needs to be repaired.
item.flags = RPG_ITEM_ARTIFACT|RPG_ITEM_PREMIUM|RPG_ITEM_SOULBOUND|RPG_ITEM_INDESTRUCTIBLE
Now, we define the look of this item. Bitmap is the image seen on the character's inventory screen and when 'investigated'. The material is how the item looks on the 3d character, materials are found here: ~\test.game\data\shapes\character\textures\arms.
item.bitmap = "EQUIPMENT/ARMS/16" item.slots = (RPG_SLOT_ARMS,) item.material = "tset_0_arms" item.desc = ""
Finally, we assign stats to this item:
item.armor = 250 item.addStat("str",100) item.addStat("dex",100) item.addStat("mnd",100) item.addStat("ref",100) item.addStat("bdy",100) item.addStat("resistMagical", 10) item.addStat("resistPhysical", 10) item.addStat("maxHealth", 100) item.addStat("maxMana", 50)
2. We'll use the clone feature to create the other 4 body armor pieces, changing only the necessary parameters:
item = item.clone() item.name = "Andarrian Chest" item.armor = 500 item.bitmap = "EQUIPMENT/CHEST/9" item.slots = (RPG_SLOT_CHEST,) item.material = "tset_0_body" item = item.clone() item.name = "Andarrian Leggings" item.armor = 250 item.bitmap = "EQUIPMENT/LEGS/16" item.slots = (RPG_SLOT_LEGS,) item.material = "tset_0_legs" item = item.clone() item.name = "Andarrian Gloves" item.armor = 150 item.bitmap = "EQUIPMENT/HANDS/2" item.slots = (RPG_SLOT_HANDS,) item.material = "tset_0_hands" item = item.clone() item.name = "Andarrian Boots" item.armor = 200 item.bitmap = "EQUIPMENT/FEET/13" item.slots = (RPG_SLOT_FEET,) item.material = "tset_0_feet"
3. It is time to suit up Guard Andarry in his new armor! Open ~\test.game\genesis\zone\zoneone\spawns.py. Add the following text to his spawn:
loot = DBLootProto() loot.addItem("Andarrian Sleeves", RPG_FREQ_ALWAYS) loot.addItem("Andarrian Chest", RPG_FREQ_ALWAYS) loot.addItem("Andarrian Leggings", RPG_FREQ_ALWAYS) loot.addItem("Andarrian Gloves", RPG_FREQ_ALWAYS) loot.addItem("Andarrian Boots", RPG_FREQ_ALWAYS) spawn.loot = loot
Guard Andarry will now drop each of these items off his corpse every time. Players will also be able to visibly see these items on him.
4. He no longer needs the other textures assigned to him, so we can remove the following block of text from his spawn:
spawn.textureArms = "tset_0_arms" spawn.textureLegs = "tset_0_legs" spawn.textureBody = "tset_0_body" spawn.textureHands = "tset_0_hands" spawn.textureFeet = "tset_0_feet"
*Note: if he didn't drop his sleeves every time, for example, you would want to consider leaving the textureArms assigned otherwise his arms would appear bare if he didn't have the sleeves.
5. Save the file, select World -> Compile World and verify that there are no errors in the message window.
Complex Item Creation - Weapon
Let's give the guard a weapon to patrol with. Again, since this is a weapon specifically for Guard Andarry we'll save it in the ~\test.game\genesis\zone\zoneone\items.py file.
1. First we set up a basic item prototype.
item = DBItemProto()
Next, we tell the game that this will be a weapon and that it's a unique item. Unique means that the item is dropped from mobs only.
item.itemType = ['UNIQUE', 'WEAPON']
Next, we give the weapon a name and tell the game what weapon skill is required to wield it.
item.name = "Sword of Andarry" item.skill="2H Slash"
Now we set the item's level. Note: players under level 20 will be able to wield this weapon but will suffer a penalty for not meeting the minimum requirement.
item.level = 20
Set the maximum repair state.
item.repairMax = 10
The next lines set the damage/rate of the weapon. These affect how much damage-per-second the weapon will do. Higher damages and lower rates, mean faster, more deadly weapons. We also set the range to 2. Most melee weapons are a '2', meaning you have to be in close to use it.
item.wpnDamage = 20 item.wpnRate = 18 item.wpnRange = 2
Now, we assign the slot that the weapon can be equipped in. If you were making a 1H weapon or if you wanted a weapon to be able to be power-wielded(the ability to equip 2 2-handed weapons), you could setup the slots as (RPG_SLOT_PRIMARY, RPG_SLOT_SECONDARY). Notice in the slots command there seems to be an unnecessary comma after the slot. This is needed for it to work and it's an easy thing to miss, so watch out for it.
item.slots = (RPG_SLOT_PRIMARY,)
For flags, you can set RPG_ITEM_INDESTRUCTIBLE, RPG_ITEM_ARTIFACT, RPG_ITEM_SOULBOUND. The flags are spliced together, separated with a "|", so it would look like this:
item.flags = RPG_ITEM_INDESTRUCTIBLE|RPG_ITEM_ARTIFACT|RPG_ITEM_SOULBOUND
To make an item unique, as in only one may be wielded by a character, give it a flag of RPG_ITEM_UNIQUE. It is unnecessary in this example because the axe can only be wielded in the primary slot.
These last 3 lines describe the weapon and give it an icon and model to use in game.
item.bitmap = "EQUIPMENT/SWORDS/24" item.model = "weapons/sword01.dts" item.desc = "This sword contains burn marks along its keen edge."
Item bitmaps are used for the icon you see when you loot a weapon, or when you look at your inventory screen. These bitmaps can be found in ~\test.game\data\ui\items. All you have to do is supply the folder names under "items" as there is only one item per folder.
Item models are found in ~\test.game\data\shapes\equipment. Look around under there and find the one you want to use.
Ok, now we have a weapon defined. Let's add it to Guard Andarry's loot table.
First, save this file.
2. Open ~\test.game\genesis\zone\zoneone\spawns.py
Locate Guard Andarry's spawn. We previously added armor to his loot table, now let's add the sword:
loot.addItem("Sword of Andarry",RPG_FREQ_COMMON)
Obviously the first parameter is the name we defined earlier. The second parameter tells the game how often the mob should have this item. Possibilities are RPG_FREQ_ALWAYS, RPG_FREQ_COMMON, RPG_FREQ_UNCOMMON, RPG_FREQ_RARE, RPG_FREQ_VERYRARE, and RPG_FREQ_IMPOSSIBLE.
3. Save the file, select World -> Compile World and verify that there are no errors in the message window.
4. Select World -> Edit Zone and load zoneone. Use /imm gimme Sword of Andarry to give yourself the sword. Verify that its stats and description are showing up correctly and that you can equip the weapon (if you meet armor and level requirements).
5. That was fun...now let's add some spell effects to the sword! Type /camp and exit the game. Locate the sword in: ~\test.game\genesis\zone\zoneone\items.py.
We'll just add a simple effect to this weapon, for a more complete description of creating spells, see the Spells tutorial section.
Effects are created and then added to spells. The spell will then get added to the weapon, therefore the effect must exist prior to the spell and the spell must exist prior to the sword. We are going to give the weapon a chance of dishing out some additional physical damage. Add the following text preceding the item = DBItemProto() for the 'Sword of Andarry' to set up an effect prototype:
effect = DBEffectProto(name = "Andarry Physical")
Now, to define what the effect is and a chance that the effect will be resisted:
effect.addDamage(RPG_DMG_PHYSICAL,50) effect.resist = RPG_RESIST_PHYSICAL
Now, we'll set up the spell and attach the effect to it:
spell = DBSpellProto() spell.name = "Andarry Physical" spell.particleTextureBegin = "blood" spell.particleBegin = "ChimneyFireEmitter" spell.target = RPG_TARGET_OTHER spell.duration = 0 spell.castTime = 0 spell.harmful = True spell.beginMsg = "$tgt has been sliced by the Sword of Andarry!" spell.sndBegin = "sfx/Hit_MetalPoleImpact2.ogg" spell.addEffect("Andarry Physical")
********add blood particle to my.mmorpg************
We named our spell the same as our effect, just for ease of use, they do not need to be the same.
A quick run-through of these parameters:
- particleTextureBegin - is the particle used when the effect 'goes off' or 'procs'. Particles can be found here: ~\test.game\data\shapes\particles
- particleBegin - defines the behavior of the particle when it is emitted.
- target - is who is affected by the spell. In this case it targets whomever the player has targeted and is fighting.
- duration - is how long the spell effect lasts.
- castTime - refers to how long it takes for the spell to be cast once it is activated.
- harmful - is set to true in this instance but some spells are beneficial and would be defined as false.
- beginMsg - is the message displayed in the combat window when the spell is activated notifying the player of its success.
- sndBegin - is the sound effect heard when the spell is activated. Additional sounds can be found here: ~\test.game\data\sound\sfx
Now, we need to assign the spell to the weapon, by adding the following text to the 'Sword of Andarry':
item.addSpell("Andarry Physical",RPG_ITEM_TRIGGER_MELEE,20)
Above, we assigned the spell, added it to only trigger during combat, and the chance of it happening.
6. Save the file, select World -> Compile World and verify that there are no errors in the message window.
7. Select World -> Edit Zone and load zoneone. Give yourself the sword by typing: /imm gimme Sword of Andarry and test out the effect.
Return to Tutorials

