From eb2cc3de51f25a0012a636a0a4a6d2d4bb0ae179 Mon Sep 17 00:00:00 2001 From: Kyle Austad Date: Sat, 25 Jan 2025 14:39:51 -0700 Subject: [PATCH] Update Quick Start --- Quick-Start.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/Quick-Start.md b/Quick-Start.md index afeb22c..9afbe87 100644 --- a/Quick-Start.md +++ b/Quick-Start.md @@ -18,4 +18,53 @@ The last two steps go hand in hand. We need to add functions for our new effect We also need to make sure our new functions have the same signature as the others with an input variable of type *actor* and an input variable of type *float*. The easiest way to do this is to simple duplicate a function in the start category and rename it and do the same for a function in the end category. -![](https://git.crabinteractive.com/crabdev/SimpleSpellsWiki/raw/branch/main/Pics/QuickStart/3.png) \ No newline at end of file +![](https://git.crabinteractive.com/crabdev/SimpleSpellsWiki/raw/branch/main/Pics/QuickStart/3.png) + +Once that is done, open the *AC_SpellManager* Actor Component blueprint. Open the function *ApplySpellEffect*. Here is a simple function that switches based on the spell effect to call the correct effect on the intended target. Simply drag off the Switch node from your new effect (If it isn't visible, right click on the switch node and hit 'refresh node') and search for you new function. In this case mine is called *Fortify Mana Start* and add that function to the execution of that effect. Duplicate the *Target*, *Caster*, and *Strength* variables from the other functions and plug them in to your new function. + + +![](https://git.crabinteractive.com/crabdev/SimpleSpellsWiki/raw/branch/main/Pics/QuickStart/4.png) + + +![](https://git.crabinteractive.com/crabdev/SimpleSpellsWiki/raw/branch/main/Pics/QuickStart/5.png) + +Once that is finished, do the same thing in the *RemoveSpellEffect* function for your newly created effect. + +![](https://git.crabinteractive.com/crabdev/SimpleSpellsWiki/raw/branch/main/Pics/QuickStart/6.png) + +## Implement the new effect + +Last thing to do is to actually make our new effect do something. So on the player pawn *BP_FirstPersonCharacter* (which can be found in *SpellPlayground/Demo/FirstPerson/Blueprints*) we need to implement our new interface function for starting and ending our effect. So with the pawn blueprint open, on the left under *Interfaces* we need to find our newly created start and end functions for our Fortify Mana spell. Double click the *FortifyMana_Start* and the *FortifyMana_End* to get an event node for those functions. + + +![](https://git.crabinteractive.com/crabdev/SimpleSpellsWiki/raw/branch/main/Pics/QuickStart/7.png) + + +![](https://git.crabinteractive.com/crabdev/SimpleSpellsWiki/raw/branch/main/Pics/QuickStart/8.png) + +For this demo effect, it should use the included stat component for tracking player and NPC health, mana and stamina and increase the mana by the strength. So we simply need to drag a reference to the *AC_Demo_Stats* component into our graph and call an included function on that component called *Increase Max Mana*. + +![](https://git.crabinteractive.com/crabdev/SimpleSpellsWiki/raw/branch/main/Pics/QuickStart/9.png) + +![](https://git.crabinteractive.com/crabdev/SimpleSpellsWiki/raw/branch/main/Pics/QuickStart/10.png) + +Then for the Fortify Mana End function we do the same thing but call the *Decrease Max Mana* function from our demo stats component reference. + +![](https://git.crabinteractive.com/crabdev/SimpleSpellsWiki/raw/branch/main/Pics/QuickStart/11.png) + +### Prevent Effect Stacking + +Spell effects trigger each second using a custom timer component so that the event that is called when the timer triggers is unique to each spell effect. Certain effects though we do not want to re-apply every second the timer triggers. Fire damage is an example of a spell we do want that behavior because a spell that has 5pts of strength for 5 seconds duration will apply 5 points each second or tick of the timer totaling 25pts of damage. Fortify Mana or Fortify Health however we do not want to be adding the strength to our max each second. We simply want it to add the amount once and keep the amount at the new max for the duration of the spell, and then when the spell ends, reset the max to the previous value. + +To solve this, in the *AC_SpellManager* component there are two variables. *SpellEffectsToResetOnReApply* and *SpellEffectsThatShouldNotTickPerTimerCount* (a mouthful I know but I wanted them to be clear). These are arrays of spell effects and have two distinctions. *SpellEffectsToResetOnReApply* simply resets the timer of that effect when the same effect is cast on a target who already has that effect, i.e. it will prevent stacking but will make the effect last the newly casted duration. *SpellEffectsThatShouldNotTickPerTimerCount* on the other hand can stack, i.e. have multiple of the same effect on a target. However they do not trigger the effect every second the timer component ticks. For example if we cast a *Summon Follower* spell and it is in the *SpellEffectsToResetOnReApply* array but not in the *SpellEffectsThatShouldNotTickPerTimerCount* then the demo implementation of the summon effect will be called each second that spell is active on the target but it will be the same effect. So the same summon spell effect will be called each second resulting in a new follower each second. If it wasn't in *SpellEffectsToResetOnReApply* but was in *SpellEffectsThatShouldNotTickPerTimerCount* then we could have multiple followers as the effect would stack but each second an effect is active it wouldn't reapply the effect, i.e. summon a new follower. + +So for our example effect, Fortify Mana, we want it to be in both arrays. You could have fortify spells stack if you want by leaving them out of *SpellEffectsToResetOnReApply* but for this example I do not want Fortify Mana to stack. So add an entry to each variable with our new effect. This will prevent Fortify Mana from stacking and it will prevent the effect from being called each second the effect is active on the target. + +## Adding the spell to the player's spell list + +With all that done, your new spell is ready to go! The player can craft the spell at the demo spell crafting altar! Give it a try! However, if you want to manually create a spell to be in the player's spell list when the game starts, we can do that. Re-open our pawn blueprint *BP_FirstPersonCharacter* and select the *AC_SpellManager* from the list of components. In the details panel find the category called Spells and add a new element to the array variable *Owned Spells*. + + +![](https://git.crabinteractive.com/crabdev/SimpleSpellsWiki/raw/branch/main/Pics/QuickStart/12.png) + +Expand your newly added element and fill out the details of your spell. A name, description, icon, casting animation and \ No newline at end of file