Morrowind
0 of 0

File information

Last updated

Original upload

Created by

KirbonatedBeverage

Uploaded by

KirbonatedBeverage

Virus scan

Safe to use

About this mod

A library/code module that adds support for a perk system, a la the fallout games

Requirements
Permissions and credits
Changelogs
MWSE Perk Framework is the evolution of the Perk System I designed for my character progression mod. The Perk Framework allows mod authors to create and register "Perks", similar to the mechanic seen in the Fallout franchise. These perks can either be included into a global list, to be used with large scale perk overhaul (like in KCP) or can be manually rewarded through other sources.

Registering Perks

Perks can be registered with the createPerk{} function. createPerk accepts a table parameter and accepts the following possible values:
  • id (string)- (required), this should be a unique string, similar to an Editor ID. Since perk data is indexed by ID, this MUST be completely unique
  • name (string)- (required) the Player-Facing name of the perk
  • description(string) -(required) A short player-facing description of the perk's effects.
  • isUnique(boolean) - if set to true, this perk will not be included in the Default Perk list (see Opening the Perk Menu) Use this if you only want the perk to be awarded from a specific source, and not to be able to be acquired from KCP or any other hypothetical mods that use this framework
  • lvlReq (number)- the Required Character level that must be reached for the player to be able to select the perk. Defaults to 0 if not specified
  • attributeReq (table)- this must be a table of attribute requirements, indexed by attribute name. this does not support OR behavior, only AND behavior ex.) {strength = 50, endurance = 60}
  • skillReq (table) - similar to attributeReq, but for required skills. ex.) {illusion = 50, shortBlade = 70, handToHand = 35}
  • werewolfReq (boolean) - if set to true, only werewolf players can take the perk
  • vampireReq (boolean) - if set to true, only vampire players can take the perk
  • perkReq (table) - an array-style table of perkIDs, representing the perks must be previously acquired to take this one. ex.) {"some PerkID", "some other perkID"}
  • customReq (function) - If a function is passed here, it will be ran whenever the framework checks the requirements for a perk. If it does not return true, the perk will not be available for the player to acquire. ex.) customReq = function() if tes3.player.object.name == "fargoth" then return true else return false end end
    --fargoth only perk lol
  • customReqText (string) - Unique text to display in the requirements section, intended to be used with customReq, but can be used on it's own
  • perkExclude (table) - this can be a table of perk IDs that player must NOT have in order to acquire the perk. This can be used to make perks that are mutually exclusive with each other
  • hideInMenu (boolean) - if set to true, the perk will only be visible in the perk selection menu if the requirements to select it are met.
  • delayActivation (boolean) - if set to true, the perk will not be immediately activated, meaning that it will not send an activation event and will not add any spells to the player. The perk can be activated later using the activatePerk() function
  • spells (table) - a table of tes3spell objects to be added to the player upon the perks activation
createPerk returns the table that stores the data of the perk

Opening the Perk Menu
In order to award perks to the player, youneed to open a perk selection menu (see images for an example). This menu can have a custom name, and can either pull from a common list of perks, or a custom set of perks can be provided in the function call

showPerkMenu{params}
  • perkPoints(number): Required - Number of perks the player can select
  • perkList(table[perkID]): Optional -  overwrite perks list with a specific list of perkIDs. if not set this defaults to the default perk list
  • header(String): Optional - overwrite the header text for the menu
  • ignoreReq(Boolean): Optional - If true, Makes all entries in the perk list selectable, even if their requirements are not met

Making Use of Perks
There are a lot of ways to use perks, due to the open nature of their design:
  • Spells - The most straightforward way to use perks to make a corresponding ability or power and use the perk as a means of giving it to the player
  • As a Script Object - When a perk gets activated, a flag in its data table, "activated" is set to true. this flag is also manually updated on game load
  • As an event trigger - Perks also send an event, "KBPerks:perkActivated", when they get activated. this event contains the event data "perk" which returns the id of the perk that was activated
  • a record of every perk the player has taken is recorded in tes3.player.data.mwsePerks.perks, and activated perks are recorded in tes3.player.data.mwsePerks.activatedPerks. Both tables store boolean values indexed by perkIDs

Other Functions

some other functions that may be useful:
  • perk.activatePerk(id), activates the perk with the associated ID
  • perk.deactivatePerk(id) deactivates the perk with the given ID. THIS DOES NOT REMOVE THE PERK FROM THE PLAYER
  • perk.getPerk(id) fetches the data table for the given perkID
  • player.grantPerk(id) grants a perk to the player, performing any necessary operations, such as perk activation
  • player.removePerk(id) removes a perk from the player, performing any necessary operations, such as perk deactivation