This is a guide on how to use the system to create a new item.
Relevant Scripts
Class
Description
ItemDefinitionSO
This is the basis of each items’ Scriptable Object. It includes all the basic stats for each item such as name, rarity, stacking type and formula, conditions and effects.
ItemEffectConfig
Instantiates ItemEffects and includes information for each effect such as whether the effect is mandatory, whether it triggers procs, effect range, trigger type and proc chance percentage (the chance of the item activating after the relevant proc is fired).
ItemEffect
The logic executed by the item.
ItemInstance
A copy of the item definition and current stack count.
UnitInventory
Holds a units items. When a proc fires, the TriggerProcs method is called, and activates all relevant items.
SharedActions
Calls TriggerProcs on the relevant UnitInventory at the right time depending on the proc fired and the proc trigger type of the item.
ProcSources
The definitions of all the proc types.
EffectParameters
The definitions of all the effect parameters. These are used to add unique numbers / other values to different ItemEffects.
Proc Flow Timeline
Something publishes a proc to the EventBus (eg. EventBus.Publish()…).
GameObserverRelay recieves the event from the EventBus and calls the relevant SharedActions method depending on the proc fired (eg. ApplyDamage() for OnHit procs, ApplyHeal() for OnHeal procs etc.).
SharedActions calls the TriggerProcs method on the units’ UnitInventory. This triggers all items for the relevant proc.
UnitInventory searches through all its stored ItemInstances and checks each ItemEffectConfig.triggerType for the relevant proc.
For matching effect configs, it checks the procChancePercentage and the EffectCondition.CheckCondition(). This will determine if the item has all the correct conditions to activate.
If all these conditions pass, the UnitInventory will call ItemEffect.Execute().
SharedActions resumes, finishing the proc with any changes from the item activation now being applied to the proc.
Some procs have multiple trigger types that determine where in the order the relevant items and effects will be activated. These procs have three different stages. This is used to allow us to change proc stats at different times in its lifetime and ensure that certain items and effects only activate after any modifiers have been added.
Trigger Type
Timeline
OnDamageDealt
Called before damage is calculated
OnPreDamageTaken
Called before damage is applied to target
OnPostDamageTaken
Called after damage is applied to target
OnHealGiven
Called when source unit is about to give a heal
OnPreHealTaken
Called before heal is applied to target
OnPostHealTaken
Called after heal is applied to target
OnShieldGiven
Called when source unit is about to give shield
OnPreShieldTaken
Called before shield is applied to target
OnPostShieldTaken
Called after shield is applied to target
Stack Types
EStackType
What it scales
DamageAmount
Damage added to a hit
AvoidDamageChance
Chance to evade incoming damage (0-1, where 0 = 0% and 1 = 100%)
AddTargets
Increase the number of additional targets hit by the effect
BaseStatsIncrease
Multiplier added to base unit stats
DamageReductionMultiplier
Percentage by which incoming damage is reduced
HealthPercent
Percentage of max health restored
MultiplierBoost
General multiplier
FlatBoost
General flat bonus added to a value
Proc Types
Proc
When it fires
OnTurnStart
When a participant’s turn starts
OnTurnEnd
When a participant’s turn ends
OnDamageDealt
When the item owner (source unit) deals damage (before damage is applied to target)
OnPreDamageTaken
When the item owner is about to receive damage
OnPostDamageTaken
When the item owner has just received damage
OnKill
When the item owner kills another unit
OnStatusGained
When the item owner gains a status effect
OnMovement
When the item owner moves to a new cell
OnDeath
When the item owner dies
OnItemGained
When the item owner picks up an item
OnHealGiven
When the item owner heals another unit
OnPreHealTaken
When the item owner is about to receive a heal
OnPostHealTaken
When the item owner has just received a heal
OnShieldGiven
When the item owner gives a shield to another unit