Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.
Tyler edited this page Mar 19, 2018 · 1 revision

Perks

The term "Perk" covers everything from magic spells, to combat abilities, to queued actions, to passive bonuses and so on. They are purchased with Skill Points (SP) which players acquire by leveling up their skills.

Creating New Perks

Creating new perks is a multi-step process. We hope to streamline this with an external tool in the future but for now it requires manual SQL queries.

Note: There is a script named AddPerkLevels.sql which is located in nwn/database/scripts/ This script can be edited to help you add new entries to the database.

1.) Insert a new row to the PerkCategories table. If you want to use an existing category, you can skip this step.

  • PerkCategoryID - The unique ID of the category.
  • Name - The name of the perk category. This is displayed in-game.
  • IsActive - If 1, it will display in the in-game menu. If 0, it won't.
  • Sequence - This is the order in which the category will display in-game.

2.) Insert a new row to the CooldownCategories table. If you want to use an existing category or if your perk does not have a cooldown, you can skip this step.

  • CooldownCategoryID - The unique ID of the cooldown.
  • Name - The name of the cooldown category. This isn't displayed in-game.
  • BaseCooldownTime - The amount of time, in seconds, before a user can activate a perk in this category. Keep in mind, this is the base amount which may be adjusted by other factors such as skill levels, stats, other perks and so on.

3.) Insert a new row to the Perks table.

  • PerkID - The unique ID of the perk.
  • Name - The name of the perk. This is displayed in-game.
  • FeatID - If you want to give a permanent feat to a player as soon as this is purchased, set it to the feat ID (located in feats.2da). Generally, feats are granted based on equipment used or other criteria, so if you don't want to use this simply set it to NULL.
  • IsActive - If 1, this perk will display in the in-game menu. If 0, it won't.
  • JavaScriptName - The name of the Java script to use. This should be organized by the category/role of the perk.
  • BaseManaCost - The amount of mana this spell costs. Keep in mind, this number might be adjusted by other factors such as equipment, skill levels, other perks, and so on. The number here is not necessarily the number you'll see in-game.
  • BaseCastingTime - The amount of time it takes to cast the spell. All disclaimers for BaseManaCost apply here too.
  • Description - The in-game description of what the perk does. This is an overarching view of the perk - don't get into specifics for this because we'll display those in the PerkLevels table later.
  • PerkCategoryID - The ID number of the category this perk falls under.
  • CooldownCategoryID - The ID number of the cooldown category. This references the CooldownCategories table. Leave NULL if this perk doesn't have a cooldown.
  • ExecutionTypeID - The ID number of the execution type to use for this perk. This references the PerkExecutionTypes table. The behaviour of the perk is determined by this flag.
  • ItemResref - The resref of the item which is used by players to activate this perk. The only time you need this is if the player needs to actively use the perk. Passive perks and NWN-based feats should not have an item.
  • IsTargetSelfOnly - This determines whether the feat item (which is given with ItemResref) will be targetable only to the user or if other objects can be targeted. Set to 1 if it's only for the user, set to 0 for everything else.

4.) Insert new rows for every level available for purchase for this perk.

  • PerkLevelID - This is an auto-generated value that you don't need to insert.
  • PerkID - The ID of the perk you just created.
  • Level - The level of this entry. You should start with 1 and increase by 1 sequentially.
  • Price - The amount of SP this level costs.
  • Description - The bonus description. These should be specific upgrades such as "+1 STR" so that players know what they're getting.

5.) Insert new rows for every level which has skill requirements into the PerkLevelSkillRequirements table. If the perk level doesn't have skill requirements you can skip this step.

  • PerkLevelSkillRequirementID - This is an auto-generated value that you don't need to insert.
  • PerkLevelID - The ID number of the perk level(s) you just inserted. This is the primary key of the row in the SkillLevels table.
  • SkillID - The skill ID for this requirement. References the Skills table.
  • RequiredRank - The required rank in the specified skill that a player must reach before being able to purchase the perk. If this is 0, the requirement won't be displayed in-game but the perk can still be purchased.

6.) Add an entry to the Enumerations.PerkID class which specifies the ID number of the perk you just inserted.

7.) Create a class which implements the IPerk interface. This should be located in the Perks library at the same location you specified in step 3 for the JavaScriptName column.

  • CanCastSpell - Any custom checks you want to do before the spell is cast. This is run once at the beginning of the casting process and again right before applying the effects. Return true if the spell can be cast or return false if the spell cannot be cast.
  • CannotCastSpellMessage - You can specify a message here if your custom checks in CanCastSpell are not met. If return value is null or empty string, a generic error message will be sent to the caster.
  • ManaCost - If you want to run any custom code to calculate the mana cost, this is the place to do it. If you don't, simply return the baseManaCost which is passed in.
  • CastingTime - If you want to run any custom code to calculate the casting time, this is the place to do it. If you don't, simply return the baseCastingTime which is passed in.
  • CooldownTime - If you want to run any custom code to calculate the cooldown time, this is the place to do it. If you don't, simply return the baseCooldownTime which is passed in.
  • OnImpact - This is the logic fired when the perk's effect is applied. This is where you put your specific effects and other actions, such as visual effects. This only fires for actionable perks such as spells and combat abilities.
  • OnPurchased - This fires one time after the perk is purchased.
  • OnRemoved - This fires one time after the perk is removed.
  • OnItemEquipped - This fires one time after an item is equipped. Note that ALL items will run this code. You must write your own logic to filter out the ones you don't care about.
  • OnItemUnequipped - Same as OnItemEquipped, but fires when items are unequipped.
  • IsHostile - If the spell is detrimental, you should return true so that PVP rules take effect. Otherwise return false.

8.) Create any perk items, if necessary. These should have a tag and resref named the same as what you specified for ItemResref in step #3.

Clone this wiki locally