-
Notifications
You must be signed in to change notification settings - Fork 0
Features
Pie adds a variety of new features to items in Kristal, spanning both the Item and HealItem classes. The built in features for Pie aim to expand the capabilities of items to make them more flexible. All features' behaviour are defined by new values added to these classes. See below for a list of features and how to control them.
All features can be controlled through two methods:
- Setting new variables inside of
item:init() - Overriding
getfunctions in theitemobject. Inside of the item file, these methods would look similar to the code blocks below:
-- Excepts of stained_apron.lua from the example library.
-- Here, passive healing is set up by setting variables inside of `item:init()`.
local item, super = Class(Item)
function item:init()
super:init(self)
-- Normal item definitions go here
-- Here, the variables for this item's passive healing are set.
self.passive_heal = true
self.passive_heal_amount = 20
self.passive_heal_frequency = 2
end
return item-- Excerpts of jelly_boots.lua from the example library.
-- Here, passive healing is set up by overriding the default getter functions of this item.
local item, super = Class(Item)
function item:init()
super:init(self)
-- Normal item definitions go here
end
-- Below, the getter functions are overriden to return the values for passive healing.
-- Sidenote: getters for booleans are prefixed 'does', but serve the same purpose.
function item:doesPassiveHeal(chara)
return true
end
-- Getter functions reveal the chara instance of the item holder, perfect for creating character-specific behaviour!
function item:getPassiveHealAmount(chara)
-- Heals 1/10th of the holder's max hp.
return chara:getStat("health") / 10
end
function item:getPassiveHealFrequency(chara)
return 1
end
return itemWhen retrieving a defined value for an item, always use the get function and never the variable - if the associated get is not overriden, the default function will return the variable anyway, but the variable will not update to reflect the output of the get function if overriden. As such, these variables should only be referenced when defining them, and getters should always be used to retrieve their values.
Currently, Pie supports the following new features:
Passive Healing in Pie does exactly what the name suggests - it heals a battler by a certain amount every given number of turns. This can also optionally deduct tension as a cost for healing the battler. If the party tension is lower than the Tension cost, the battler will not be healed, and tension will not be withdrawn. Additionally, if the battler has maximum health, they will not receive healing, and tension will not be withdrawn.
Passive Healing can be added to equipment and its behaviour controlled by the following variables and getters:
-
passive_heal(boolean): Whether the item can conduct passive healing.falseby default. -
doesPassiveHeal(chara)(boolean): Returns a boolean representing whether the item can conduct passive healing or not. Returnspassive_healby default. -
passive_heal_amount(integer): The amount of health restored by this item. -
getPassiveHealAmount(chara)(integer): Returns the amount of health restored by this item. By default,passive_heal_amountis returned. -
passive_heal_cost(integer): The tension cost of passive healing for this item. -
getPassiveHealCost(chara)(integer): Returns the tension cost of passive healing for this item. By default,passive_heal_costis returned. -
passive_heal_frequency(integer): The number of turns between heals, with1healing every turn.1by default. -
getPassiveHealFrequency(chara)(integer): Returns the number of turns between heals, with1healing every turn. Returnspassive_heal_frequencyby default.
Passive Tension Regeneration behaves in the same way as Passive Healing, but tension and health have their roles reversed - tension is restored and health is used as the cost (if one exists) and, likewise, if not enough health is present, tension will not be restored, or if tension is full, no health will be withdrawn.
Passive Tension Regeneration can be added to equipment and its behaviour controlled by the following variables and getters:
-
passive_tension(boolean): Whether the item can conduct passive tension restoration.falseby default. -
doesPassiveTension(chara)(boolean): Returns a boolean representing whether the item can conduct passive tension restoration or not. Returnspassive_tensionby default. -
passive_tension_amount(integer): The amount of tension restored by this item. -
getPassiveTensionAmount(chara)(integer): Returns the amount of tension restored by this item. By default,passive_tension_amountis returned. -
passive_tension_cost(integer): The health cost of passive tension regeneration for this item. -
getPassiveTensionCost(chara)(integer): Returns the health cost of passive tension restoration for this item. By default,passive_tension_costis returned. -
passive_tension_frequency(integer): The number of turns between tension restores, with1triggering every turn.1by default. -
getPassiveTensionFrequency(chara)(integer): Returns the number of turns between tension restores, with1triggering every turn. Returnspassive_tension_frequencyby default.
Passive item generation takes a slightly more abstract principle than other passive effects - rather than healing or restoring tension, it instead focuses on granting items to the party. As with the other passive effects, it still follows the same set of rules, and can charge both health and tension to grant items.
Passive Item Generation can be implemented and controlled on equipment by using the following variables and getters:
-
passive_item(boolean): Whether this item can passively grant other items to the party.falseby default. -
doesPassiveItem(chara)(boolean): Returns whether this item can passively grant other items to the party. By default, this is set to returnpassive_item. -
passive_item_name(string): The name of the passive item to be given to the party. Must be able to go into theitemsstorage. -
getPassiveItemName(chara)(string): Returns the name of the passive item to be given to the party. By default, this is set to returnpassive_item_name. -
passive_item_tensioncost(integer): The amount of tension withdrawn when given this item. -
getPassiveItemTensionCost(chara) _(integer)_: Returns the amount of tension withdrawn when given this item. By default, this is set to returnpassive_item_tensioncost`. -
passive_item_healthcost(integer): The amount of health deducted upon giving this item. -
getPassiveItemHealthCost(chara) _(integer)_: Returns the amount of health dedcuted upon giving this item. By default, this is set to returnpassive_item_healthcost`. -
passive_item_frequency(integer): The number of turns between each item being generated, with1being every turn.1by default. -
getPassiveItemFrequency(chara) _(integer)_: Returns the number of turns between each item being generated. By default, this is set to returnpassive_item_frequency`.
Passive damage is another of the passive effects available, functioning as the inverse of healing; Unsurprisingly, passive damage deals damage to the holder of the item over time, however, unlike the main trio of passive effects, this one has no settable cost (because who would want to pay to be hurt?) as well as being able to kill the holder if they are hurt too much.
Note: this can not be used to replicate a Thorn Ring-styled health sapping effect.
Passive Damage can be added to equipment and controlled using the following variables and getters:
-
passive_hurt(boolean): Whether the item can inflict passive damage.falseby default. -
doesPassiveHurt(chara)(boolean): Returns a boolean representing whether the item can inflict passive damage or not. Returnspassive_hurtby default. -
passive_hurt_amount(integer): The amount of damage inflicted by this item. -
getPassiveHurtAmount(chara)(integer): Returns the amount of damage inflicted by this item. By default,passive_hurt_amountis returned. -
passive_hurt_frequency(integer): The number of turns between each hit, with1hitting every turn.1by default. -
getPassiveHurtFrequency(chara)(integer): Returns the number of turns between hits, with1hitting every turn. Returnspassive_hurt_frequencyby default.
Healing boosts are a bonus applicable to equipment that increases how effective HealItem healing is, functioning alike the Burnt Pan from UNDERTALE. Heal bonuses can also be multiplicative, specifying a factor to multiply by, which takes priority over additive bonuses if set.
The following variables and getters can be used to give items Healing Boosts:
-
heal_bonus(integer): The amount of bonus health restored when the holder of this item uses aHealItem. -
heal_bonuses(table): A table that specifies the amount of bonus health restored when the holder of this item uses aHealItemwith a specific id. Each key, value pair should be an item id and an integer for the heal bonus. -
getHealBonus(chara, item)(integer): Returns the amount of bonus health restored when the holder of this item uses aHealItem. By default, this returnsheal_bonuses[item.id]orheal_bonusif it is not set. -
multiplicative_heal_bonus(float): The factor to multiply item healing by when the holder of this item uses aHealItem. -
multiplicative_heal_bonuses(table): A table of factors to multiply item healing by for specificHealItemids. Each key, value pair should be an item id and a float for the multiplication factor. -
getMutliplicativeHealBonus(chara, item)(float): Returns the multiplication factor for healing when the holder of this item uses aHealItem. By default, this returnsmultiplicative_heal_bonuses[item.id]ormultiplicative_heal_bonusif it is not set. -
block_heal_bonus(boolean): Settable on anyHealItem. Iftrue, its healing cannot be affected by heal bonuses.
Victory healing is a bonus applicable to equipment that restores health to the wearer when the battle ends.
The following variables and getters can be used to give items Victory Healing:
-
victory_heal(integer): The amount of health restored at the end of battle. -
getVictoryHealAmount(chara)(integer): Returns the amount of health restored at the end of battle. By default, this will returnvictory_heal.
Starting tension is a bonus applicable to equipment that gives the party tension at the start of battle.
The following variables and getters can be used to give items Starting Tension:
-
starting_tension(integer): The amount of tension granted at the start of battle. -
getStartingTensionAmount(chara)(integer): Returns the amount of tension granted at the start of battle. By default, this will returnstarting_tension.
Future Heals are a new method of healing for any HealItem, usable in conjunction with normal healing, or on its own.
The following variables and getters can be used to give healing items Future Healing:
-
future_heal_amount(integer): The amount of health restored through future healing. -
future_heal_turns(integer): The amount of turns the future healing will take place in. -
getFutureHealAmount(chara)(integer): Returns the amount of health restored through future healing. By default, this will returnfuture_heal_amount. -
getFutureHealTurns(chara)(integer): Returns the number of turns before future healing will occur for this item. By default, this will returnfuture_heal_turns.
Attack Dodging allows equipment to have a dodge chance, allowing an item holder to completely negate an entire hit of damage.
The following variables and getters can be used to give items Attack Dodging:
-
dodge_chance(float): A value between 0 and 1 that determines the chance of a dodge being triggered. -
getBaseDodgeChance(chara)(float): Returns a value between 0 and 1 that determines the chance of a dodge being triggered. Returnsdodge_chanceby default. -
dodge_defend_bonus(float): A value between 0 and 1 that is added tododge_chancewhilst defending. -
getDodgeDefendBonus(chara)(float): Returns a value between 0 and 1 that determines the bonus dodge chance whilst defending. Returnsdodge_defend_bonusby default. - `getDodgeChance(chara, defending) (float): Returns a value between 0 and 1 representing the dodge chance for this item, combining both the dodge chance and bonus (if it should apply).
-
dodge_color(table): A table of floats that represent the RGB color of the "miss" text to display on a successful dodge. -
getDodgeColor(chara)(table): Returns a table of floats that represent the RGB color of the "miss" text to display on a successful dodge. Returnsdodge_colorby default. -
dodge_sound(string): A string referencing the name of the sound to play upon a successful dodge. Set to "none" for no sound, defaults to "mus_sfx_a_pullback" (Asriel's sword pullback sfx from Undertale). -
getDodgeSound(chara) _(string)_: Returns a string referencing the name of the sound to play on a successful dodge. Returnsdodge_sound` by default.
Thorns allows equipment to have a chance to hurt an enemy for a proportion of the damage dealt to the holder of the item.
The following variables and getters can be used to give items Thorns:
-
thorns_chance(float): A value between 0 and 1 that determines the chance of thorns being triggered. -
getBaseThornsChance(chara)(float): Returns a value between 0 and 1 that determines the chance of thorns being triggered. Returnsthorns_chanceby default. -
thorns_defend_bonus(float): A value between 0 and 1 that is added tothorns_chancewhilst defending. -
getThornsDefendBonus(chara)(float): Returns a value between 0 and 1 that determines the bonus dodge chance whilst defending. Returnsdodge_defend_bonusby default. - `getThornsChance(chara, defending) (float): Returns a value between 0 and 1 representing the thorns chance for this item, combining both the thorns chance and bonus (if it should apply).
-
thorns_damage_proportion(float): A value between 0 and 1 that reflects the proportion of damage that should be dealt to an enemy. -
getThornsDamageProportion(chara) _(float)_: Returns a value between 0 and 1 that reflects the proportion of damage that should be dealt to an enemy. Returnsthorns_damage_proportion` by default. -
thorns_sound(string): A string referencing the name of the sound to play upon thorns. Set to "none" for no sound, defaults to "screenshake". -
getDodgeSound(chara) _(string)_: Returns a string referencing the name of the sound to play on successful thorns. Returnsthorns_sound` by default.
Attack reflecting allows equipment to have a chance to reflect a proportion of damage to its holder back at an enemy.
The following variables and getters can be used to give items Attack Reflecting:
-
reflect_chance(float): A value between 0 and 1 that determines the chance of reflection being triggered. -
getBaseReflectChance(chara)(float): Returns a value between 0 and 1 that determines the chance of reflection being triggered. Returnsreflect_chanceby default. -
reflect_defend_bonus(float): A value between 0 and 1 that is added toreflect_chancewhilst defending. -
getReflectDefendBonus(chara)(float): Returns a value between 0 and 1 that determines the bonus dodge chance whilst defending. Returnsreflect_defend_bonusby default. - `getReflectChance(chara, defending) (float): Returns a value between 0 and 1 representing the reflection chance for this item, combining both the reflect chance and bonus (if it should apply).
-
reflect_damage_proportion(float): A value between 0 and 1 that represents the proportion of damage that should be reflected to an enemy. -
getReflectDamageProportion(chara) _(float)_: Returns a value between 0 and 1 that represents the proportion of damage that should be reflected to an enemy. Returnsreflect_damage_proportion` by default. -
reflect_sound(string): A string referencing the name of the sound to play upon attack reflection. Set to "none" for no sound, defaults to "bell_bounce_short". -
getReflectSound(chara) _(string)_: Returns a string referencing the name of the sound to play on successful reflection. Returnsreflect_sound` by default.
Pie includes some config options visible inside of lib.json that can be overriden inside mod.json to alter library behaviour.
alwaysDoHealItemHealing (boolean): When true, HealItems will always call heal(), even if they would restore 0 hp (standard Kristal behaviour). When false, they will not call heal() and therefore will not produce the healing effect. false by default.
alwaysApplyHealBonus (boolean): When true, heal bonuses will always apply to items, even if they originally healed nothing. Otherwise, bonuses will not apply to items with 0 hp of healing. false by default.
passiveHurtCanKill (boolean): When true, passive hurt items can knock down battlers through their damage. true by default.
passiveEffectCostCanKill (boolean): When true, passive item effects with a hp cost can knock down battlers with hp damage. false by default.
The implementation of some of the above features has also resulted in new functionality for some other parts of Kristal. Although not technically primary features of this library, they can be used by any part of a mod as they are necessary. These features are as follows:
PartyMember:futureHeal(amount, turns) - Used internally by Future Heal items, this function can be called from any PartyMember whilst in battle to create a new future heal.
-
amount(integer): The amount of health to restore. -
turns(integer): The number of turns to restore health in.
self.future_heals (PartyMember) - A table of all pending future heals. Just like PartyMember:futureHeal(), it is used internally for Future Heal items.
This does only take about 5 seconds to manually implement, but a feature is a feature either way!
-
turn(Encounter) - Reflects the current turn of the battle. Starts at 1, and is increased inEncounter:onTurnEnd().
Note: If Pie behaves strangely or causes unexpected interactions inside a mod, it may be a result of several instances of
turnbeing incremented in the Encounter object. If this is the case, all other instances ofturnbeing set/modified should be removed.
Heal bonuses are managed by the PartyMember performing the healing, given that they are holding all the items that should apply their bonuses. As a little bonus, this allows for extending PartyMember:applyHealBonus() to make a PartyMember have bonus healing independent of items.
This can be achieved with code such as:
local PartyMember, super = Class(PartyMember)
function PartyMember:applyHealBonus(amount, item)
-- Call super:applyHealBonus() to apply all of the item bonuses first.
local new_amount = super:applyHealBonus(self, amount, item)
-- Add 10 bonus HP to all healing done by this PartyMember.
new_amount = new_amount + 10
-- Return the final amount.
return new_amount
end
return PartyMember