Intermediate Tutorial: Adding an Item which uses Special Abilities

This tutorial assumes that you already know the basics of adding an item. If you do not, please see Basic Tutorial: Adding an Item.

In this tutorial, we will create an item that uses Special Abilities to accomplish our goal of modifying one of the characters. For the example item, we'll create a "Thinking Cap" which raises a character's intelligence score to 18 when the item is readied, and returns the intelligence to it's original value when unreadied.

    Adding Thinking Cap

  1. Here's how I've set up the Thinking Cap. Click the "Magical Props" button to activate the Magical Properties Dialog.
  2. Magical Properties Dialog

  3. Leave everything as is - we're only concerned with adding a Special Ability, so click that button.
  4. Special Abilities Dialog

  5. Click "Add" to bring up the "Edit Attribute Value" dialog.
  6. Enter the name of the Special Ability, in this case "item_ThinkingCap". The name can be anything that you like, but it is much easier to keep things straight if you use a naming scheme that is both informational and functional. Note, you need not create the Special Ability first - we will do that in upcoming steps. Do write down or remember the name you have written so that you can create the Special Ability - the spelling must be exact and is case and space sensitive.
  7. The parameter can be anything, and may actually be something which the Special Ability uses. For example, you may create a Special Ability that is used by several different objects, and you might list the object name as the parameter so that other Special Abilities will know which object called the Special Ability.
  8. Click "OK" until you are back to the main Item Editor window and "OK" again. The rest of our work will be done in the Special Abilities Editor.
  9. This tutorial assumes that you know the basics of using the Special Ability Editor. If you do not, please see Basic Tutorial: Adding a Special Ability.

    Adding a Hook

  10. After adding the "item_ThinkingCap" Special Ability, we need to add a pair of scripts to it. Since we want the Special Ability to take effect when the character puts the Thinking Cap on (readies the item), we will use the OnReadyXxx Hook, where the Xxx represents the body part name - in this case 'Helm'. (See OnReadyXxx for a complete list of names.)
  11. The "Value" field requires something be entered before we can continue, and since this is a much longer script than in the basic tutorial, enter a couple of characters that we can delete when we have Script Editor open.
  12. Hit "OK" and with the Hook highlighted, choose "Script" so that Dungeon Craft knows how to handle this. Open the Script Editor.
  13. Script Editor

  14. In the Script Editor enter the script for this Hook:
    $VAR target;
    target = $MyIndex();
    $SET_CHARACTER_SA($Myself(),"thinkingCap",18-#$GET_CHAR_INT(target));
    $SET_CHAR_INT(target,18);
    	
    This script creates an ad hoc Special Ability called "thinkingCap" that stores a value that is the difference between 18 and the character's intelligence score. We use the difference instead of the value, because other things may raise or lower the character's intelligence while the Thinking Cap is being worn. Don't forget to use "Test Syntax" to make sure you haven't mistyped or forgotten something.
  15. Adding a Hook

  16. Since we want the character's intelligence to return to normal when the Thinknig Cap is removed, we need to use the matching Hook to OnReadyHelm, which is OnUnReadyHelm.
  17. As with earlier, put some characters in the "Value" box that we will change in the Script Editor.
  18. After you have clicked "OK", select the new Hook we have just added and mark it as a "Script" so that Dungeon Craft handles it properly
  19. Script Editor

  20. In the Script Editor enter the script for this Hook:
    $VAR target;
    target = $MyIndex();
    $SET_CHAR_INT(target,$GET_CHAR_INT(target)-#$SA_CHARACTER_GET("thinkingCap"));
    $DELETE_CHARACTER_SA($Myself(),"thinkingCap");
    	
    This script recalls the value we stored in the ad hoc "thinkingCap" Special Ability and subtracts that from the current intelligence score. It then deletes the "thinkingCap" Special Ability so that if character uses this item again and it's intelligence score has changed, the proper numbers will be used. Don't forget to use "Test Syntax" to make sure you haven't mistyped or forgotten something.
  21. Click "OK" until the Special Ability Editor is closed and save your work.

With new database items, it is always a good idea to try them out while you are getting used to the ins and outs of Dungeon Craft and GPDL scripting. I recommend adding a Give Treasure event and using the test feature to have a character put on (Ready) and take off (Unready) the Thinking Cap to make sure it works properly.


Back to Design Tutorials

Back to Designer's Guide Index