Using & Utilizing Cloaks
There is a lot of misinformation about Cloaks being spread, how bad they are or that they are unnecessary. Bu they are in fact an incredibly powerful tool and like any tool, you simply need to know how to use it.
Basics of a Cloak
Before we get started, I wish to clarify some names I will be using in the following text:
A Cloak is a spell-structure put together by 2 Spells and 2 or more Effects:
- The "Cloak Spell": The spell applied the actor distributing the cloak effect
- The "Cloak Effect": The associated magic effect which has the "Cloak" archetype and is responsible for applying the desired effect to surrounding actors
- The "Application Spell": The "Concentration/Aimed" type spell that is being casted onto every valid actor in range. The Caster of this Spell will be the Target of the Cloak spell
- The "Application Effect": One or more effects applied by the Application Spell. This is where the various effect/s applied by the Cloak is found at
When to use a Cloak
Strongly simplified, a Cloak is essentially a Trigger Box that you put on an Actor (Im going to refer to this Actor as Source going forward). In this picture, the only notable difference between a Cloak and a Trigger Box is that the Cloak is always moving with the Source - The Source will always be defining the center of it. To make this clear, a Trigger Box has 3 Events associated to it:
- OnTriggerEnter (Fired when an Object enters the Box)
- OnTriggerLeave (Fired when an Object leaves the Box)
- OnTrigger (Periodically fired while an Object is inside the Box)
A Cloak has no issues mimicking this exact behavior -> Create a Script on the Application Effect and have it listen for those Events:
- OnEffectStart (Fired when Actor gets close to the Source)*
- OnEffectFinish (Fired when an Actor leaves the Source)*
- OnUpdate (Periodically fired while an Object is near the Source)*/**
*Assuming a Cloak Duration of 1+ Seconds
**This should be avoided if possible. Its not very reliable and often creates a lot of Errors on the log. If you see yourself putting a Polling on a Cloak you should just move to a Quest instead
With this in mind, it should be obvious that you can do pretty much anything you want with a cloak, from simple "trigger box" things, like increasing a quest stage to complicated gameplay effects, like blacking out the players game when they get too close to some enemy
-
Apply Spell Effects
The most basic application of a cloak spell: You want to apply some magic effect to all actors in range, like a Damage effekt? Thats the basic idea behind Cloaks, and it is very useful for a variety of things. You can use it not only to apply damage effects, but also to do things such as applying a detect life effect to all enemies nearby. And yes, we are talking about giving the player wall hacks there! -
Waiting for specific types of actors
Imagine you are working on a quest which wants some random actors, like a Hunter in the wild, to approach the player when they get close to you. There are a couple ways to do this: The first one is a polling, like a quest polling, that periodically looks for actors in the area. The downside of a polling? Its slow, or the polling is so short that it burns a lot of Papyrus ressources
A cloak on the other hand is entirely controlled by the engine, the impact on performance from the cloak itself is negligible and its very fast to notify when there is some actor that fits your profile. Your Hunter will be found the second they get close to the player. Simple as that! -
Listen for actor events near the source actor
One of the more advanced things (and arguably more dangerous ones) that you can do with a Cloak is to monitor every actor in the environment by some condition. How is that dangerous? Because resources, especially Papyrus ones, arent unlimited
There are instances where you want to do something with all Actors close by, like checking if they are being hit by some attack from one of your followers and Cloak can do a good job here as well. More reactive, unlike quest pollings. The danger is introduced by a small detail: You cannot control how many actors "everyone" is. Cloaks will attach themselves to every valid actor in the environment and when 13 Actors start receiving continuous OnHit events, your Papyrus engine may struggle to keep up pretty quickly
This doesnt mean that you shouldnt be using Cloaks for this but you should consider how you manage a potential influx in actors close by. Use conditions and refine them as much as possible, beware of thread safety and use "Busy States" to skip processing OnHit events that you dont want to receive
Also note that while SPID has its advantages, it isnt save from this problem. It will face the very same issues that a Cloak does here and may even worsen it, as you have less control over when actors are affected by a SPID spell -
Apply permanent effects
A cloak is intended to apply temporary effects. Thats what its made for, thats what its good at. Applying permanent effects, piggy back riding cloaks to apply these, can create a variety of issues and makes managing your spells incredibly difficult
If you ever come into a situation where you feel like you need to apply permanent spell effects to a large amount of actors, consider using SPID instead
Cloak vs Quest vs SPID
When it comes to polling actors, applying some scripted effect to them, the 3 most common methods are: Quests, Cloaks and SPID. This urges the question: Which method is best to use in some given situation? And as with all things, it depends on what you want to do. Cloaks, Quests and SPID all have their advantages and disadvantages and there is no definite answer to what you should be using in any given situation, instead consider how your environment looks and what exactly you want to use the actors you gather for:
- Quests is a centralized polling method. They are by far the most powerful option to choose from when you want to use the actors you gathered for.. something. They offer you Keywords, Packages, Factions, Spells, Scripts, Information about all collected actors, dialogue, and more free house which makes them incredibly versatile and useful for building stories and interactive experiences. Things that require some centralized processing, something that is in charge of everything. However: they are slow and only as responsive as their underlying polling and have an upper limit on how many actors they can process (This may or may not be a good thing)
- Cloaks are decentralized, temporary and highly reactive. They are incredibly powerful to manage actors that dont need to interact with another, that dont need to be stored into some central quest. Or for situations in which you only want to react to some specific Events (like an actor approaching you or a certain spell hitting another actor). On the downside, they can become quite expensive on the Papyrus side of things, when used incorrectly
-
SPID is very similar to cloaks when it comes to applying scripts to a variety actors. The most important difference is that its effects are permanent as opposed to temporary, they are also easier to manage as it is only 1 spell, as opposed to the 2 spell construct that a cloak uses which simplifies their usage but also means that you cant make use of the relation between caster and target in script and spell/effect conditions. It will otherwise face the same issues as a cloak does
When it comes to SPID or Cloak, it is often a question about how dynamic the application should be. Do want to run conditions that check for relation between caster and target (like hostility)? Do you want to remove the effect again at some later point; is the effect still necessary to be there are something happened?
Miscellaneous Information on Cloaks & their Effects
- The magnitude defines the range of the cloak. The ratio is 1:20, i.e. for each magnitude the cloak gains 20 units of range. The in the CK Wiki stated 1:1 ratio is wrong
- The area of a cloak spell is ignored
- The duration of the applied effect should be greater than the interval at which Cloak spells are updated (at least 1s), otherwise the Cloak will be reapplied continuously, which has bad implications for the games performance and also may create some unexpected bugs on your end. The duration of the effect is then equal to how long the effect lasts after the actor goes out of range of the cloak
-
Like any other Spell, the Application Spell too has Spell-Side and Effect-Side Conditions. Those Conditions create the following behavior:
- both Spellside & Effectside are checked constantly, there is no performance difference
-
both Spellside & Effectside will send an "OnEffectFinish()" Event when their Condition becomes invalid
- however, only Effect-Side Conditions causes the Effect to be dispelled and not be reapplied. The Spell-Side Condition does fire the Event but does not remove or stop reapplication of the Effect
-
both Spellside & Effectside will send an "OnEffectStart()" Event when their Condition becomes valid
- even if in Case of Spell-Side Conditions, the Spell has never actually been removed
- In Conditions, the "Target" Actor is the Caster of the Spell - here: The Source. E.g. asking if "Subject.IsHostileToActor( [TARGET] )" will check if the wearer of the Application Spell is hostile towards the Source. This applies to all Spells afaik but I believe its important to be noted here especially in case you only want to apply this Cloak to targets standing in Relation to the Source
An Example for Condition Behavior:
I have a Spell "Make Actor Sad" and a Condition "Is Actor Happy?"
If I put my Condition on the Spell directly and then cast the Cloak, a Happy Actor would turn Sad. A Sad Actor isnt Happy so the Condition is no longer valid but the Spell will stay on the Actor
If I put my Condition on my Effect instead and then cast the Cloak, a Happy Actor would turn Sad. A Sad Actor isnt Happy so the Condition is no longer valid and because of that, the "Make Actor Sad" Spell would be removed from the Actor again, make him Happy again and with that, valid again for the Effect, the Effect would then be reapplied with the next cloak interval
Edited by Scrab
1 Comment
Recommended Comments