This is a guide on how to use the system to create a new item.

Relevant Scripts

ClassDescription
ItemDefinitionSOThis 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.
ItemEffectConfigInstantiates 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).
ItemEffectThe logic executed by the item.
ItemInstanceA copy of the item definition and current stack count.
UnitInventoryHolds a units items. When a proc fires, the TriggerProcs method is called, and activates all relevant items.
SharedActionsCalls TriggerProcs on the relevant UnitInventory at the right time depending on the proc fired and the proc trigger type of the item.
ProcSourcesThe definitions of all the proc types.
EffectParametersThe definitions of all the effect parameters. These are used to add unique numbers / other values to different ItemEffects.

Proc Flow Timeline

  1. Something publishes a proc to the EventBus (eg. EventBus.Publish()…).
  2. 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.).
  3. SharedActions calls the TriggerProcs method on the units’ UnitInventory. This triggers all items for the relevant proc.
  4. UnitInventory searches through all its stored ItemInstances and checks each ItemEffectConfig.triggerType for the relevant proc.
  5. 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.
  6. If all these conditions pass, the UnitInventory will call ItemEffect.Execute().
  7. 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 TypeTimeline
OnDamageDealtCalled before damage is calculated
OnPreDamageTakenCalled before damage is applied to target
OnPostDamageTakenCalled after damage is applied to target
OnHealGivenCalled when source unit is about to give a heal
OnPreHealTakenCalled before heal is applied to target
OnPostHealTakenCalled after heal is applied to target
OnShieldGivenCalled when source unit is about to give shield
OnPreShieldTakenCalled before shield is applied to target
OnPostShieldTakenCalled after shield is applied to target

Stack Types

EStackTypeWhat it scales
DamageAmountDamage added to a hit
AvoidDamageChanceChance to evade incoming damage (0-1, where 0 = 0% and 1 = 100%)
AddTargetsIncrease the number of additional targets hit by the effect
BaseStatsIncreaseMultiplier added to base unit stats
DamageReductionMultiplierPercentage by which incoming damage is reduced
HealthPercentPercentage of max health restored
MultiplierBoostGeneral multiplier
FlatBoostGeneral flat bonus added to a value

Proc Types

ProcWhen it fires
OnTurnStartWhen a participant’s turn starts
OnTurnEndWhen a participant’s turn ends
OnDamageDealtWhen the item owner (source unit) deals damage (before damage is applied to target)
OnPreDamageTakenWhen the item owner is about to receive damage
OnPostDamageTakenWhen the item owner has just received damage
OnKillWhen the item owner kills another unit
OnStatusGainedWhen the item owner gains a status effect
OnMovementWhen the item owner moves to a new cell
OnDeathWhen the item owner dies
OnItemGainedWhen the item owner picks up an item
OnHealGivenWhen the item owner heals another unit
OnPreHealTakenWhen the item owner is about to receive a heal
OnPostHealTakenWhen the item owner has just received a heal
OnShieldGivenWhen the item owner gives a shield to another unit
OnPreShielsGivenWhen the item owner is about to receive a shield
OnPostShieldGivenWhen the item owner has just received a shield